public IActionResult RankMovies(PrivateGroupRankMoviesViewModel rankMoviesViewModel) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var movieWatcher = _context.MovieWatchers.Where(m => m.IdentityUserId == userId).FirstOrDefault(); var privateGroup = _context.PrivateGroups.Where(m => m.Name == rankMoviesViewModel.GroupName).FirstOrDefault(); MovieRanking movieRanking = new MovieRanking(); movieRanking.MovieRating1 = rankMoviesViewModel.MovieRating1; movieRanking.MovieRating2 = rankMoviesViewModel.MovieRating2; movieRanking.MovieRating3 = rankMoviesViewModel.MovieRating3; movieRanking.MovieRating4 = rankMoviesViewModel.MovieRating4; movieRanking.MovieRating5 = rankMoviesViewModel.MovieRating5; privateGroup.MovieRanking = movieRanking; _context.PrivateGroups.Update(privateGroup); _context.SaveChanges(); movieWatcher.MyPrivateGroup = privateGroup; _context.MovieWatchers.Update(movieWatcher); _context.SaveChanges(); //int numberOfPeopleInGroup = rankMoviesViewModel.MovieWatchers.Count; //int totalRating = rankMoviesViewModel.MovieRating1; //int averageRatingOfMovie = totalRating / numberOfPeopleInGroup; //MovieRanking movieRanking = new MovieRanking(); //movieRanking.MovieRating1 = averageRatingOfMovie; //var privateGroup = _context.PrivateGroups.FirstOrDefault(g => g.Id == rankMoviesViewModel.GroupId); //< input type = "hidden" asp -for= "GroupId" value = "@Model.PrivateGroup.Id" /> return(RedirectToAction("VoteOnMovies")); }
public IActionResult RankMovies() { PrivateGroupRankMoviesViewModel rankMoviesViewModel = new PrivateGroupRankMoviesViewModel(); //foreach (var person in movieWatchers) //{ //} return(View(rankMoviesViewModel)); }