Exemple #1
0
        public IActionResult AddRecipe(RecipeModel recipe, string ingredientCSV, string instructionCSV)
        {
            recipe.Ingredients  = IngredientModel.ingredientCSVtoDTO(ingredientCSV).ToList();
            recipe.Instructions = InstructionModel.instructionCSVtoDTO(instructionCSV).ToList();

            recipeManager.Add(RecipeModel.ModelToDto(recipe));

            return(RedirectToAction("RecipeIndex"));
        }
Exemple #2
0
        public IActionResult CreateRecipe([FromBody] RecipeViewModel.Create r)
        {
            r.CreatorId = User.Claims.FirstOrDefault(c => c.Type == "UserId").Value;
            List <string> errorCodes = ControlRecipe(r);

            if (errorCodes.Count > 0)
            {
                return(BadRequest(errorCodes));
            }

            Recipe recipe = RecipeManager.Add(r);

            return(CreatedAtRoute("GetRecipe", new { recipe.Id }, recipe));
            //return CreatedAtRoute("CreateRecipe", recipe);
        }