Exemplo n.º 1
0
 private void DeleteRemainingIngredients(Ingredient[] ingredientsFromRequest, List <Ingredient> dbIngredients)
 {
     dbIngredients.ForEach(dbI =>
     {
         if (!ingredientsFromRequest.Where(i => i.Id == dbI.Id).Any())
         {
             _ingredientsRepository.DeleteIngredient(dbI);
         }
     });
 }
Exemplo n.º 2
0
        public RedirectToRouteResult Delete(int ingredientID)
        {
            Ingredient ingredient = (from i in ingredientsRepository.Ingredients
                                     where i.IngredientID == ingredientID
                                     select i).First();

            ingredientsRepository.DeleteIngredient(ingredient);
            TempData["message"] = "Ингредиент " + ingredientID + " удален";

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public MyResponse DeleteIngredient(int id, string userId)
        {
            Ingredient ingredient     = GetIngredient(id);
            MyResponse validateResult = ValidateDeleteIngredient(ingredient, id, userId);

            if (validateResult.IsSuccess())
            {
                _ingredientsRepository.DeleteIngredient(ingredient);
            }
            return(validateResult);
        }
Exemplo n.º 4
0
 public ActionResult Delete(int id)
 {
     try
     {
         _ingredientsRepository.DeleteIngredient(id);
         _ingredientsRepository.Save();
         return(StatusCode(200));
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }