public async Task <IActionResult> Create([Bind("Id,Name")] Variety variety) { if (ModelState.IsValid) { _context.Add(variety); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(variety)); }
public async Task <IActionResult> Create([Bind("Id,Unit,Quantity")] Amount amount) { if (ModelState.IsValid) { _context.Add(amount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(amount)); }
public async Task <IActionResult> Create([Bind("Id,Name,Description,RecipeCategory")] Recipe recipe) { if (ModelState.IsValid) { _context.Add(recipe); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(recipe)); }
public async Task <IActionResult> Create([Bind("Id")] RecipeIngredient recipeIngredient) { if (ModelState.IsValid) { _context.Add(recipeIngredient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(recipeIngredient)); }
public async Task CreateTag(Tag tag) { var tagExists = await _recipeDb.Tags .AnyAsync(t => t.Value.Equals(tag.Value, StringComparison.OrdinalIgnoreCase)); if (tagExists) { throw new ArgumentException("Tag already exists."); } _recipeDb.Attach <Tag>(tag); await _recipeDb.SaveChangesAsync(); }
public async Task CreateRecipe(Recipe recipe) { _recipeDb.Attach <Recipe>(recipe); await _recipeDb.SaveChangesAsync(); }