Ejemplo n.º 1
0
 @RequestMapping(
     value = "/movies/{movieId}",
     method = RequestMethod.POST,
     headers = "Accept=text/html")
 public String updateMovie(
     Model model,
     @PathVariable String movieId,
     @RequestParam(value = "rated", required = false) Integer stars,
     @RequestParam(value = "comment", required = false) String comment) {
   Movie movie = moviesRepository.getMovie(movieId);
   User user = userDetailsService.getUserFromSession();
   moviesRepository.rateMovie(
       movie, user, stars == null ? -1 : stars, comment != null ? comment.trim() : null);
   return singleMovieView(model, movieId);
 }
Ejemplo n.º 2
0
 private User addUser(Model model) {
   User user = userDetailsService.getUserFromSession();
   model.addAttribute("user", user);
   return user;
 }