public ActionResult Create([Bind(Include = "Text,MovieId")] NewReviewBindingModel review) { if (ModelState.IsValid) { var loggedUserId = User.Identity.GetUserId(); var reviewId = this._service.Add(review, loggedUserId); return(RedirectToAction("Details", new { id = reviewId })); } return(View(review)); }
public int Add(NewReviewBindingModel review, string userId) { var newReview = Mapper.Map <NewReviewBindingModel, Review>(review); newReview.DateTime = DateTime.Now;; newReview.Movie = this.Context.Movies.Find(review.MovieId); newReview.Reviewer = this.Context.Users.Find(userId); this.Context.Reviews.Add(newReview); this.Context.SaveChanges(); return(newReview.Id); }