public int CreateRestaurant(Restaurant restaurant) { var result = _restaurantRepo.CreateRestaurant(restaurant); if (result) { return(_restaurantRepo.GetLatestRestaurantId()); } return(0); }
public ActionResult CreateRestaurant(Restaurant restaurant) { try { if (ModelState.IsValid) { restaurantRepo.CreateRestaurant(restaurant); return(RedirectToAction("RestaurantList")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(restaurant)); }