public ActionResult Edit(int id, Review reviewModel) { var review = this.Data.Reviews.Find(id); if (review == null) { return HttpNotFound(); } if (reviewModel.Content != null) { review.Content = reviewModel.Content; review.Author = review.Author; review.Game = review.Game; this.Data.SaveChanges(); var reviewDb = this.Data.Reviews.Find(review.Id); return this.Content(reviewDb.Content); } return this.Content("<h3 class='text-danger'>Error! Content can not be empty.</h3>"); }
public ActionResult AddReview(Review commentModel, int id) { if (commentModel != null) { var review = new Review() { CreationTime = DateTime.Now, Content = commentModel.Content, Author = this.Data.Users.All().FirstOrDefault(u => u.UserName == this.UserProfile.UserName), Game = this.Data.Games.Find(id) }; this.Data.Reviews.Add(review); this.Data.SaveChanges(); var reviewDb = this.Data.Reviews.All() .FirstOrDefault(c => c.Id == review.Id); var model = Mapper.Map<Review, TopFiveReviewsViewModel>(reviewDb); return this.PartialView("DisplayTemplates/TopFiveReviewsViewModel", model); } return this.Json("Error"); }