public async Task <IActionResult> Create([Bind("Id,Name")] Store store) { if (ModelState.IsValid) { _context.Add(store); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(store)); }
public async Task <IActionResult> Create([Bind("Id,Name,StoreId")] Ingredient ingredient) { if (ModelState.IsValid) { _context.Add(ingredient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ingredient)); }
public async Task <IActionResult> Create([Bind("Id,Name,Description,Servings,ServingsOurs")] Recipe recipe) { if (ModelState.IsValid) { _context.Add(recipe); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(recipe)); }
public async Task <IActionResult> Create([Bind("ShoppingListId,RecipeId,Quantity")] ShoppingListRecipe shoppingListRecipe) { if (ModelState.IsValid) { _context.Add(shoppingListRecipe); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ShoppingListId"] = new SelectList(_context.ShoppingList, nameof(ShoppingList.Id), nameof(ShoppingList.Name), shoppingListRecipe.ShoppingListId); ViewData["RecipeId"] = new SelectList(_context.Recipe, nameof(Recipe.Id), nameof(Recipe.Name), shoppingListRecipe.RecipeId); return(View(shoppingListRecipe)); }
public async Task <IActionResult> Create([Bind("RecipeId,IngredientId,Quantity,UnitId")] RecipeIngredient recipeIngredient) { if (ModelState.IsValid) { _context.Add(recipeIngredient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IngredientId"] = new SelectList(_context.Ingredient, nameof(Ingredient.Id), nameof(Ingredient.Name), recipeIngredient.IngredientId); ViewData["RecipeId"] = new SelectList(_context.Recipe, nameof(Recipe.Id), nameof(Recipe.Name), recipeIngredient.RecipeId); ViewData["UnitId"] = new SelectList(_context.Unit, nameof(Unit.Id), nameof(Unit.Name), recipeIngredient.UnitId); return(View(recipeIngredient)); }