예제 #1
0
        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));
            }
        }
예제 #2
0
        //[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 })));
            }
        }
예제 #3
0
        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());
            }
        }