コード例 #1
0
        public ActionResult AddIngredients(IngredientListViewModel ingredients)
        {
            List <IngredientsRecipeBL> ingredientList = new List <IngredientsRecipeBL>();

            foreach (var i in ingredients.ListIngredients)
            {
                ingredientList.Add(new IngredientsRecipeBL()
                {
                    Quantity = i.Quantity,
                    Name     = i.Name
                });
            }

            foreach (var i in ingredientList)
            {
                var id = ingredientService.CheckIfIngredientExists(i.Name);
                ingredientService.InsertIngredientForRecipe(ingredients.RecipeID, id, i.Quantity);
            }

            return(RedirectToAction("Add", "Instructions", new InstructionsListViewModel
            {
                NrOfInstructions = ingredients.NrOfInstructions,
                RecipeID = ingredients.RecipeID
            }));
        }