Esempio n. 1
0
    public MyResponse UpdateRecipeWithIngredients(RecipeWithIngredients recipeWithIngredients, string userId)
    {
        MyResponse updateResult = UpdateRecipe(recipeWithIngredients.Recipe, userId);

        if (updateResult.IsFailed())
        {
            return(updateResult);
        }

        List <Ingredient> dbIngredients = _ingredientsRepository.GetIngredientsForRecipe(recipeWithIngredients.Recipe.Id);

        UpdateOrAddIngredientsToRecipe(recipeWithIngredients.Ingredients, dbIngredients, recipeWithIngredients.Recipe.Id);
        DeleteRemainingIngredients(recipeWithIngredients.Ingredients, dbIngredients);
        return(updateResult);
    }
Esempio n. 2
0
 public RecipeWithIngredients GetRecipeWithIngredients(int id)
 {
     return(new RecipeWithIngredients(
                _recipesRepository.GetRecipe(id),
                _ingredientsRepository.GetIngredientsForRecipe(id).ToArray()));
 }