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); }
public RecipeWithIngredients GetRecipeWithIngredients(int id) { return(new RecipeWithIngredients( _recipesRepository.GetRecipe(id), _ingredientsRepository.GetIngredientsForRecipe(id).ToArray())); }