public ActionResult Edit(Review review, int id) { try { review.Restaurant = applicationServices.GetReviewByID(id).Restaurant; ValidationContext context = new ValidationContext(review, null, null); List <ValidationResult> results = new List <ValidationResult>(); bool valid = Validator.TryValidateObject(review, context, results, true); if (valid) { applicationServices.UpdateReview(review); // log that it worked return(RedirectToAction("Index", new RouteValueDictionary( new { controller = "Review", action = "Index", Id = review.Restaurant.RestaurantId }))); } else { return(View(review)); } } catch { return(HttpNotFound()); } }
public ActionResult Edit(Review review) { try { review.Restaurant = applicationServices.GetReviewByID(review.ReviewId).Restaurant; applicationServices.UpdateReview(review); return(RedirectToAction("Index", new RouteValueDictionary( new { controller = "Review", action = "Index", Id = review.Restaurant.RestaurantId }))); } catch { return(View(review)); } }