Ignore:
Timestamp:
02/07/23 23:14:46 (22 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
64ee7f4
Parents:
cb5debb
Message:

trying to call a function from database

File:
1 edited

Legend:

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

    rcb5debb r8d49568  
    44import com.example.moviezone.model.*;
    55import com.example.moviezone.model.exceptions.PasswordsDoNotMatchException;
     6
    67import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
    78import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository;
     9
     10import com.example.moviezone.model.procedures.FilmsReturnTable;
     11
    812import com.example.moviezone.service.*;
    913import org.springframework.format.annotation.DateTimeFormat;
     
    1418import javax.servlet.http.HttpSession;
    1519import java.time.LocalDate;
     20import java.util.LinkedList;
    1621import java.util.List;
    1722import java.util.stream.Collectors;
     
    3540
    3641    public HomeController(FilmService filmService, UserService userService, ProjectionService projectionService, EventService eventService, TicketService ticketService, WorkerService workerService, CustomerRatesFilmService customerRatesFilmService, CinemaService cinemaService, CinemaOrganizesEventService cinemaOrganizesEventService, CinemaPlaysFilmService cinemaPlaysFilmService, ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository) {
    37        
     42
    3843        this.filmService = filmService;
    3944        this.userService = userService;
     
    127132
    128133    }
    129 
    130134    @GetMapping("/films")
    131135    public String getFilmsPage(Model model){
    132136        model.addAttribute("cinemas",cinemaService.findAllCinemas());
    133         model.addAttribute("films",filmService.findAllFilms());
     137            List<FilmsReturnTable> pom=new LinkedList<>();
     138            model.addAttribute("films",pom);
     139            boolean h=pom.isEmpty();
     140            List<FilmsReturnTable> help=filmService.getFilmsFromCinema(2);
    134141        model.addAttribute("bodyContent","films");
    135142        return "master-template";
    136143    }
    137144
     145    public String getFilmsPage1(Model model,Integer id_cinema){
     146        model.addAttribute("cinemas",cinemaService.findAllCinemas());
     147        if (id_cinema!=null) {
     148            model.addAttribute("films",filmService.getFilmsFromCinema(id_cinema.intValue()));
     149        }else{
     150            List<FilmsReturnTable> pom=new LinkedList<>();
     151            model.addAttribute("films",pom);
     152        }
     153
     154        model.addAttribute("bodyContent","films");
     155        return "master-template";
     156    }
     157    @PostMapping("/getFilmsFromCinema")
     158    public String getFilmsFromCinema(@RequestParam Integer cinema, Model model){
     159        return getFilmsPage1(model,cinema);
     160    }
    138161    @GetMapping("/projections")
    139162    public String getProjectionsPage(Model model)
Note: See TracChangeset for help on using the changeset viewer.