public void RemoveRecipe_RemoveRecipeWithIngredients_ShoppingListModelRemoveItemCalled()
        {
            const int id   = 1;
            var       list = new List <Ingredient> {
                new Ingredient()
            };

            _recipeListModel.GetRecipeById(id).Returns(new Recipe()
            {
                Ingredients = list
            });
            _uut.RemoveRecipe(id);
            _shoppingListModel.Received().RemoveItem(Arg.Any <Ingredient>());
        }
Esempio n. 2
0
        /// <summary>
        /// Removes all ingredients in a recipe from the shoppinglist
        /// and the recipe from the foodplan.
        /// </summary>
        /// <param name="recipeId">ID of recipe to remove</param>
        public async Task RemoveRecipe(int recipeId)
        {
            var recipe = await _recipeListModel.GetRecipeById(recipeId);

            if (recipe?.Ingredients?.Count > 0)
            {
                foreach (var ingredient in recipe.Ingredients)
                {
                    _shoppingListModel.RemoveItem(ingredient);
                }
            }

            await _foodplanCollector.RemoveRecipe(_loginModel.FoodplanId, recipeId);

            await Update();
        }