Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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 })));
            }
        }
Ejemplo n.º 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());
            }
        }