예제 #1
0
        public IActionResult Delete(int id)
        {
            var oldRecipe = _recipeData.GetById(id);

            if (oldRecipe == null)
            {
                return(NotFound());
            }
            _recipeData.Delete(id);
            _recipeData.Commit();
            return(Ok());
        }
예제 #2
0
        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"));
        }
예제 #3
0
        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"));
        }