public async Task <IActionResult> Create(Recipe recipe, string ingredientText)
        {
            var ingredients = await recipeServer.CreateIngredientList(ingredientText);

            var _recipe = new Recipe()
            {
                Description = recipe.Description,
                Ingredients = ingredients,
                Name        = recipe.Name
            };
            await recipeServer.AddRecipeAsync(_recipe);

            return(Redirect("/"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> EditRecip(Recipe recipe, long id, string ingredientText)
        {
            var ingredients = await recipeServer.CreateIngredientList(ingredientText);

            var _recipe = await recipeServer.FindByIdAsync(id);

            _recipe.Name        = recipe.Name;
            _recipe.Description = recipe.Description;
            _recipe.Ingredients.Clear();
            _recipe.Ingredients = ingredients;

            await recipeServer.SaveAsync();

            return(RedirectToAction(nameof(Index)));
        }