Ignore:
Timestamp:
02/10/23 11:18:48 (21 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
04153a9
Parents:
7926d68
Message:

Interested in event

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/web/HomeController.java

    r7926d68 ref84238  
    2424import java.util.LinkedList;
    2525import java.util.List;
    26 import java.util.Objects;
    2726import java.util.stream.Collectors;
    2827
     
    4645private final CustomerService customerService;
    4746private final Projection_RoomService projectionRoomService;
    48 
    49     public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService, CustomerRatesFilmService customerRatesFilmService, CinemaService cinemaService, CinemaOrganizesEventService cinemaOrganizesEventService, CinemaPlaysFilmService cinemaPlaysFilmService, ProjectionIsPlayedInRoomService projectionIsPlayedInRoomService, CategoryService categoryService, SeatService seatService, CustomerService customerService, Projection_RoomService projectionRoomService)
     47private final CustomerIsInterestedInEventService customerIsInterestedInEventService;
     48
     49    public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService, CustomerRatesFilmService customerRatesFilmService, CinemaService cinemaService, CinemaOrganizesEventService cinemaOrganizesEventService, CinemaPlaysFilmService cinemaPlaysFilmService, ProjectionIsPlayedInRoomService projectionIsPlayedInRoomService, CategoryService categoryService, SeatService seatService, CustomerService customerService, Projection_RoomService projectionRoomService, CustomerIsInterestedInEventService customerIsInterestedInEventService)
    5050    {
    5151
     
    6565        this.customerService = customerService;
    6666        this.projectionRoomService = projectionRoomService;
     67        this.customerIsInterestedInEventService = customerIsInterestedInEventService;
    6768    }
    6869
     
    412413    }
    413414    @GetMapping("/profileUser")
     415    @Transactional
    414416    public String getUserProfile(Model model,HttpServletRequest request)
    415417    {
    416418        Customer customer=customerService.findByUsername(request.getRemoteUser());
    417419        System.out.println(customer.getFirst_name());
     420        List<Event> events=eventService.getEventsForCustomer(customer.getId_user());
    418421        model.addAttribute("customer",customer);
     422        model.addAttribute("events",events);
    419423        model.addAttribute("bodyContent", "profileUser");
    420424        return "master-template";
    421425    }
     426    @PostMapping("/addInterestedEvent/{id}")
     427    public String addInterestedEvent(@PathVariable Long id,HttpServletRequest request, HttpServletResponse respons)
     428    {
     429        Customer customer=customerService.findByUsername(request.getRemoteUser());
     430        customerIsInterestedInEventService.add(customer.getId_user(),Integer.valueOf(id.intValue()));
     431        return "redirect:/profileUser";
     432    }
     433    @PostMapping("/deleteInterestedEvent/{id}")
     434    public String deleteInterestedEvent(@PathVariable Long id,HttpServletRequest request, HttpServletResponse respons)
     435    {
     436        Customer customer=customerService.findByUsername(request.getRemoteUser());
     437        Event event=eventService.getEventById(id).get();
     438        customerIsInterestedInEventService.delete(customer,event);
     439        return "redirect:/profileUser";
     440    }
    422441}
Note: See TracChangeset for help on using the changeset viewer.