public IActionResult Edit(int id, ResturantEditViewModel model) { var restaurant = _restaurantData.Get(id); if (ModelState.IsValid) { restaurant.Cuisine = model.Cuisine; restaurant.Name = model.Name; _restaurantData.Commit(); return(RedirectToAction("Details", new { id = restaurant.Id })); } return(View(restaurant)); }
public IActionResult Create(ResturantEditViewModel model) { if (ModelState.IsValid) { var newRestaurant = new Resturant(); newRestaurant.Cuisine = model.Cuisine; newRestaurant.Name = model.Name; _restaurantData.Add(newRestaurant); _restaurantData.Commit(); return(RedirectToAction("Details", new { id = newRestaurant.Id })); } return(View()); }