// // GET: /Comments/Create public ActionResult Create(int movieId) { var newComment = new CommentsModel() { MovieID = movieId }; return View(newComment); }
public ActionResult Create(CommentsModel c) { try { if (ModelState.IsValid) { var newComment = new Comment(); TryUpdateModel(newComment); Movie movie = _moviesService.Get(c.MovieID); newComment.Movie = movie; newComment.Owner = _userService.GetAuthenticatedUser(User.Identity.Name); _CommentsService.Add(newComment); return RedirectToRoute("Default", new { controller = "Movies" , action = "Details", id = c.MovieID }); } } catch (Exception e) { ModelState.AddModelError("", String.Format("Edit Failure, inner exception: {0}", e)); } return View(c); }