Changeset 3ded84d in Git for src/main/java/com/wediscussmovies/project/web/controller/MovieController.java
- Timestamp:
- 01/18/22 17:18:17 (3 years ago)
- Branches:
- main
- Children:
- e0ef1b1
- Parents:
- 7fafead
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/web/controller/MovieController.java
r7fafead r3ded84d 2 2 3 3 import com.wediscussmovies.project.exception.MovieIdNotFoundException; 4 import com.wediscussmovies.project.model.Genre; 5 import com.wediscussmovies.project.model.Movie; 6 import com.wediscussmovies.project.model.Person; 4 import com.wediscussmovies.project.model.*; 5 7 6 import com.wediscussmovies.project.service.GenreService; 8 7 import com.wediscussmovies.project.service.MovieService; … … 33 32 public String getMovies(@RequestParam(required = false) String titleQuery, Model model){ 34 33 List<Movie> movies; 35 if(titleQuery == null || titleQuery.isEmpty()) {34 if(titleQuery == null ) { 36 35 movies = movieService.listAll(); 37 36 } … … 40 39 } 41 40 42 movies.sort(Movie.comparatorTitle);43 41 44 42 model.addAttribute("movies", movies); 45 43 model.addAttribute("contentTemplate", "moviesList"); 46 return " template";44 return "list"; 47 45 } 48 46 … … 59 57 60 58 @PostMapping("/{id}/delete") 61 public String addMovie(@PathVariable Longid){59 public String addMovie(@PathVariable Integer id){ 62 60 Optional<Movie> movie = movieService.findById(id); 63 61 if(movie.isPresent()){ 64 movieService.deleteById(movie.get().get Id());62 movieService.deleteById(movie.get().getMovieId()); 65 63 } 66 64 return "redirect:/movies"; … … 122 120 123 121 Movie movie = new Movie(title, description, image_url, airing_date, 124 rating, director , actorsList, genreList);122 rating, director.getPersonId()); 125 123 126 124 movieService.save(movie); … … 131 129 @PostMapping("/edit/confirm") 132 130 public String editMoviePost( 133 @RequestParam Longmovie_id,131 @RequestParam Integer movie_id, 134 132 @RequestParam String title, 135 133 @RequestParam String description, … … 198 196 movieService.deleteById(movie_id); 199 197 200 201 movie.setDirector(director);202 movie.setGenres(genreList);203 movie.setTitle(title);204 movie.setDescription(description);205 movie.setAringDate(airing_date);206 movie.setImageUrl(image_url);207 movie.setImbdRating(rating);198 // // movie.setActors(actorsList); 199 // movie.setDirector(director); 200 // movie.setGenres(genreList); 201 // movie.setTitle(title); 202 // movie.setDescription(description); 203 // movie.setAringDate(airing_date); 204 // movie.setImageUrl(image_url); 205 // movie.setImbdRating(rating); 208 206 209 207 movieService.save(movie); … … 213 211 214 212 @GetMapping("/{id}/edit") 215 public String editMovie(@PathVariable Longid, Model model){213 public String editMovie(@PathVariable Integer id, Model model){ 216 214 Movie movie = movieService.findById(id).orElseThrow(() -> new MovieIdNotFoundException(id)); 217 215 model.addAttribute("directors", personService.findAllDirectors());
Note:
See TracChangeset
for help on using the changeset viewer.