Пример #1
0
        public async Task <IActionResult> Create([Bind("ID,RecipeID,IngredientID,Quantity")] RecipeIngredient recipeIngredient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipeIngredient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IngredientID"] = new SelectList(_context.Ingredient, "ID", "ID", recipeIngredient.IngredientID);
            ViewData["RecipeID"]     = new SelectList(_context.Recipe, "ID", "ID", recipeIngredient.RecipeID);
            return(View(recipeIngredient));
        }