//Create post public IActionResult Create(MovieCommentVM movieCommentVM) { movieCommentVM.Comment.Date = DateTime.Now; movieCommentVM.Comment.IsConfirmed = false; movieCommentVM.Movie = _db.Movie.Where(m => m.Id == movieCommentVM.Comment.IdMovie).Include(mg => mg.MovieGenres).ThenInclude(g => g.Genre).Include(am => am.ActorMovies).ThenInclude(a => a.Actor) .Include(d => d.Director).Include(ms => ms.MovieStudio).Include(c => c.Comments).FirstOrDefault(); if (ModelState.IsValid) { _db.Comment.Add(movieCommentVM.Comment); _db.SaveChanges(); } return(RedirectToAction("Details", new { id = movieCommentVM.Comment.IdMovie })); }
public IActionResult Details(int Id) { MovieCommentVM movieCommentVM = new MovieCommentVM() { Movie = _db.Movie.Where(m => m.Id == Id).Include(mg => mg.MovieGenres).ThenInclude(g => g.Genre).Include(am => am.ActorMovies).ThenInclude(a => a.Actor) .Include(d => d.Director).Include(ms => ms.MovieStudio).Include(c => c.Comments).ThenInclude(c => c.Customer).FirstOrDefault(), IdCustomer = _userManager.GetUserId(User) }; if (User.Identity.IsAuthenticated) { movieCommentVM.Comment = new Comment() { IdMovie = Id, IdCustomer = _userManager.GetUserId(User) } } ; return(View(movieCommentVM)); }