public IActionResult OnPost(int restaurantId) { var restaurant = restauranteData.Delete(restaurantId); restauranteData.Commit(); if (restaurant == null) { return(RedirectToPage("./NotFound")); } TempData["Message"] = $"{restaurant.Name} deleted."; return(RedirectToPage("./List")); }
public IActionResult OnPost() { if (!ModelState.IsValid) { Cuisines = htmlHelper.GetEnumSelectList <TipoCozinha>(); return(Page()); } //Como a página Edit é reutilizada verifica se: update ou add a restaurant if (Restaurante.Id > 0) { restauranteData.Update(Restaurante); } else { restauranteData.Add(Restaurante); } restauranteData.Commit(); return(RedirectToPage("./Detail", new { restaurantId = Restaurante.Id })); }