public async Task <IActionResult> Edit(int id, [Bind("IngredientId,NameIngredient,Price")] TIngredient tIngredient) { if (id != tIngredient.IngredientId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tIngredient); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TIngredientExists(tIngredient.IngredientId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tIngredient)); }
public async Task <IActionResult> Create([Bind("IngredientId,NameIngredient,Price")] TIngredient tIngredient) { if (ModelState.IsValid) { _context.Add(tIngredient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tIngredient)); }