public ActionResult Edit(Restaurant restaurant) { try { restaurant.Reviews = applicationServices.GetRestaurantById(restaurant.RestaurantId).Reviews; applicationServices.UpdateAverageRating(restaurant); applicationServices.UpdateRestaurant(restaurant); return(RedirectToAction("Index")); } catch { return(View(restaurant)); } }
//[Authorize("Admin")] public ActionResult Delete(int id) { try { var restaurant = applicationServices.GetReviewByID(id).Restaurant; applicationServices.RemoveReview(id); applicationServices.UpdateAverageRating(restaurant); return(RedirectToAction("Index", new RouteValueDictionary( new { controller = "Review", action = "Index", Id = restaurant.RestaurantId }))); } catch { var index = applicationServices.GetReviewByID(id).Restaurant.RestaurantId; return(RedirectToAction("Index", new RouteValueDictionary( new { controller = "Review", action = "Index", Id = index }))); } }
public ActionResult Edit(Restaurant restaurant) { if (ModelState.IsValid) { try { restaurant.Reviews = applicationServices.GetRestaurantById(restaurant.RestaurantId).Reviews; applicationServices.UpdateAverageRating(restaurant); applicationServices.UpdateRestaurant(restaurant); return(RedirectToAction("Index")); } catch { Debug.WriteLine("Not Working."); // log some problem return(HttpNotFound()); } } else { return(View()); } }