- Timestamp:
- 02/09/23 14:06:45 (21 months ago)
- Branches:
- master
- Children:
- 6a9006d, a9ffccd
- Parents:
- 0ba5d1a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/moviezone/web/HomeController.java
r0ba5d1a r00fa72f 38 38 private final ProjectionIsPlayedInRoomService projectionIsPlayedInRoomService; 39 39 private 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) 40 private final SeatService seatService; 41 private final CustomerService customerService; 42 private 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) 42 45 { 43 46 … … 54 57 this.projectionIsPlayedInRoomService = projectionIsPlayedInRoomService; 55 58 this.categoryService = categoryService; 59 this.seatService = seatService; 60 this.customerService = customerService; 61 this.projectionRoomService = projectionRoomService; 56 62 } 57 63 … … 95 101 model.addAttribute("categories",categoryService.findAllCategories()); 96 102 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"); 97 118 98 119 return "master-template"; … … 316 337 317 338 @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"; 321 352 } 322 353
Note:
See TracChangeset
for help on using the changeset viewer.