public IActionResult Edit(int id, [Bind("Id,Name,Address,Description,Rate,ImageUrl,PhoneNumber,WorkingHours,DeliveryAreas,MenuId")] Restaurant restaurant) { if (id != restaurant.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _restRepo.UpdateRestaurant(restaurant); _restRepo.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!_restRepo.RestaurantExists(restaurant.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MenuId"] = new SelectList(_menuRepo.AllMenus, "Id", "Id"); return(View(restaurant)); }
public IActionResult OnPost() { if (ModelState.IsValid) { dbContext.UpdateRestaurant(Restaurant); return(RedirectToAction("Details", "Home", new { id = Restaurant.ID })); } return(Page()); }
public IActionResult OnPost() { if (ModelState.IsValid) { if (Restaurant.Id < 1) { Restaurant = restaurantData.Add(Restaurant); } else { Restaurant = restaurantData.UpdateRestaurant(Restaurant); } restaurantData.Commit(); return(RedirectToPage("./details", new { restaurantId = Restaurant.Id })); } TempData["Message"] = "Restaurant saved"; Cuisines = htmlHelper.GetEnumSelectList <CuisineType>(); return(Page()); }