Ignore:
Timestamp:
02/09/23 14:06:45 (21 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
6a9006d, a9ffccd
Parents:
0ba5d1a
Message:

Reservation Implemented

File:
1 edited

Legend:

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

    r0ba5d1a r00fa72f  
    3838private final ProjectionIsPlayedInRoomService projectionIsPlayedInRoomService;
    3939private final CategoryService categoryService;
    40 
    41     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)
     40private final SeatService seatService;
     41private final CustomerService customerService;
     42private final Projection_RoomService projectionRoomService;
     43
     44    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)
    4245    {
    4346
     
    5457        this.projectionIsPlayedInRoomService = projectionIsPlayedInRoomService;
    5558        this.categoryService = categoryService;
     59        this.seatService = seatService;
     60        this.customerService = customerService;
     61        this.projectionRoomService = projectionRoomService;
    5662    }
    5763
     
    95101        model.addAttribute("categories",categoryService.findAllCategories());
    96102        model.addAttribute("bodyContent", "projectionsForFilm");
     103
     104        return "master-template";
     105    }
     106    @GetMapping("/getSeats/{id}")
     107    @Transactional
     108    public String getSeats(@PathVariable Long id, Model model,@RequestParam Long id_category,@RequestParam Long film) {
     109        Category category=categoryService.getCategoryById(id_category.intValue()).get();
     110        Projection projection=projectionService.findById(id.intValue());
     111        model.addAttribute("film",filmService.getFilmById(film).get());
     112        model.addAttribute("projection",projection);
     113        model.addAttribute("category",category);
     114
     115        List<Seat> seats=seatService.findAllByRoomAndCategory(projectionRoomService.getRoomByProjection(projection.getId_projection()).get(0),category);
     116        model.addAttribute("seats",seats);
     117        model.addAttribute("bodyContent", "seats");
    97118
    98119        return "master-template";
     
    316337
    317338    @PostMapping("/makeReservation")
    318     public String createTicketForReservation()
    319     {
    320         return "redirect:/myTickets";
     339    @Transactional
     340    public String createTicketForReservation(@RequestParam Long film,@RequestParam Long projection,@RequestParam Long id_seat,@RequestParam String discount)
     341    {
     342        Ticket t;
     343        Projection projection1=projectionService.findById(projection.intValue());
     344        if(projection1.getDiscount().equals(discount)){
     345            t=ticketService.saveWithDiscount(LocalDate.now(),customerService.getCustomerById(2).get(),projection1,projection1.getDiscount(),seatService.getSeatById(id_seat.intValue()).get());
     346        }else{
     347            t=ticketService.saveWithout(LocalDate.now(),customerService.getCustomerById(4).get(),projection1,seatService.getSeatById(id_seat.intValue()).get());
     348        }
     349        Integer price=ticketService.priceForTicket(t.getId_ticket());
     350        t.setPrice(price);
     351        return "redirect:/home";
    321352    }
    322353
Note: See TracChangeset for help on using the changeset viewer.