예제 #1
0
        public ActionResult AddRecipe(Recipe recipe)
        {
            // add new ingredients into the ingredient table
            if (recipe.NewIngredients.Count() > 0)
            {
                ingredientDAO.AddIngredients(recipe.NewIngredients);
            }

            // add recipe into recipes table
            recipe = recipeDAO.AddRecipe(recipe, this.UserId);

            // add recipe_id, ingredient_id, ingredient_qty, and ingredient_unit into recipes_ingredient table
            recipeIngredientDAO.AddIngredients(recipe.IngredientList, recipe.RecipeId);

            // return recipe so front end can use the recipe id
            // update recipe object so it has the ingredient id's in them?  front end doesn't need as of 4/7
            return(Created($"/recipes/{recipe.RecipeId}", recipe));
        }