public ActionResult <MyResponse> DeleteIngredient(int id) { MyResponse response = _ingredientsService.DeleteIngredient(id, GetUserId()); if (response.IsFailed()) { Response.StatusCode = 400; } return(response); }
public ActionResult <MyResponse> PutRecipe([FromBody] Recipe recipe) { MyResponse response = _recipesService.UpdateRecipe(recipe, GetUserId()); if (response.IsFailed()) { Response.StatusCode = 400; } return(response); }
public ActionResult <MyResponse> PutIngredient([FromBody] Ingredient ingredient) { MyResponse response = _ingredientsService.UpdateIngredient(ingredient, GetUserId()); if (response.IsFailed()) { Response.StatusCode = 400; } return(response); }
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); }