public IActionResult Delete(int id)
 {
     if (_repository.GetDishById(id) == null)
     {
         return(NotFound());
     }
     _repository.DeleteDish(id);
     return(NoContent());
 }
        public ActionResult Delete(int dishId)
        {
            Dish dish = repository.DeleteDish(dishId);

            if (dish != null)
            {
                TempData["message"] = string.Format("Editing in dish \"{0}\" was deleted", dish.Name);
            }
            return(RedirectToAction("DishesSummary"));
        }
Esempio n. 3
0
        public IActionResult Delete(int dishId)
        {
            Dish deletedDish = repository.DeleteDish(dishId);

            if (deletedDish != null)
            {
                TempData["message"] = $"{deletedDish.Name} was deleted";
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
 /// <summary>
 /// Method removes dish
 /// </summary>
 /// <param name="dishId">Id of user to delete</param>
 public void DeleteDish(int dishId)
 {
     try
     {
         _dishRepository.DeleteDish(dishId);
     }
     catch (Exception ex)
     {
         throw new Exception("Error while deleting dish: " + ex.Message, ex);
     }
 }