Exemple #1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // TODO: Add update logic here
                    Restaurant temp = new Restaurant
                    {
                        Id                    = id,
                        RestaurantName        = collection["restaurantName"],
                        RestaurantAddress     = collection["restaurantAddress"],
                        RestaurantCity        = collection["restaurantCity"],
                        RestaurantState       = collection["restaurantState"],
                        RestaurantPhoneNumber = collection["restaurantPhoneNumber"],
                        RestaurantURL         = collection["restaurantURL"]
                    };
                    LibHelper.EditRestaurant(temp);

                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    return(View());
                }
            }
            else
            {
                return(View("Invalid Model State"));
            }
        }
 //edit a restaurant in DB
 public void UpdateRestaurant(Restaurant restaurant)
 {
     _db.EditRestaurant(ToData(restaurant));
     //_db.SaveChanges();
 }