Ignore:
Timestamp:
02/08/23 14:40:10 (23 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
5867520, 632e3d8
Parents:
61fed7c
Message:

Events and Event

File:
1 edited

Legend:

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

    r61fed7c r90317ea  
    1616import org.springframework.web.bind.annotation.*;
    1717
     18import javax.naming.event.EventDirContext;
    1819import javax.servlet.http.HttpSession;
    1920import javax.transaction.Transactional;
     
    7980        return "master-template";
    8081    }
    81 
     82    @GetMapping("/getEvent/{id}")
     83    public String getEvent(@PathVariable Long id, Model model) {
     84        Event event =eventService.getEventById(id).get();
     85        model.addAttribute("event", event);
     86        model.addAttribute("bodyContent", "event");
     87
     88        return "master-template";
     89    }
    8290    @GetMapping("/login")
    8391    public String getLoginPage(Model model)
     
    149157        return "master-template";
    150158    }
    151 
     159    @Transactional
    152160    @GetMapping("/projections")
    153     public String getProjectionsPage(Model model)
    154     {
    155         model.addAttribute("projections",projectionService.findAllProjections());
    156         model.addAttribute("bodyContent","projections");
     161    public String getProjectionsPage(Model model,@RequestParam(required = false) Integer id_cinema)
     162    {
     163        model.addAttribute("cinemas",cinemaService.findAllCinemas());
     164        if (id_cinema!=null) {
     165            model.addAttribute("films",filmService.getFilmsFromCinemaNow(id_cinema));
     166        }else{
     167            List<FilmsReturnTable> pom=new LinkedList<>();
     168            model.addAttribute("films",filmService.getFilmsNow());
     169        }
     170        model.addAttribute("bodyContent","films");
    157171        return "master-template";
    158172    }
    159173    @GetMapping("/events")
    160     public String getEventsPage(Model model)
    161     {
    162         model.addAttribute("events",eventService.findAllEvents());
     174    @Transactional
     175    public String getEventsPage(Model model,@RequestParam(required = false) Integer id_cinema)
     176    {
     177        model.addAttribute("cinemas",cinemaService.findAllCinemas());
     178        if (id_cinema!=null) {
     179            model.addAttribute("events",eventService.getEventsFromCinema(id_cinema));
     180        }else{
     181            List<FilmsReturnTable> pom=new LinkedList<>();
     182            model.addAttribute("events",eventService.getEventsNow());
     183        }
    163184        model.addAttribute("bodyContent","events");
    164185        return "master-template";
Note: See TracChangeset for help on using the changeset viewer.