public IActionResult Delete(int id) { var oldRecipe = _recipeData.GetById(id); if (oldRecipe == null) { return(NotFound()); } _recipeData.Delete(id); _recipeData.Commit(); return(Ok()); }
public IActionResult OnPost(int recipeId) { var recipe = recipeData.Delete(recipeId); recipeData.Commit(); if (recipe == null) { return(RedirectToPage("./NotFound")); } TempData["Message"] = $"The recipe {recipe.Name} has been deleted."; return(RedirectToPage("./List")); }
public IActionResult OnPost(string recipeId) { var recipe = recipeData.Delete(recipeId); if (recipe == null) { TempData["Message"] = $"Error deleting {recipe.Name}"; } else { TempData["Message"] = $"{recipe.Name} deleted"; } return(RedirectToPage("List")); }