public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Price,Weight,Cost")] Foodstuffs foodstuffs) { if (id != foodstuffs.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(foodstuffs); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FoodstuffsExists(foodstuffs.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(foodstuffs)); }
public async Task <IActionResult> Create([Bind("Id,Name,Price,Weight,Cost")] Foodstuffs foodstuffs) { if (ModelState.IsValid) { _context.Add(foodstuffs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(foodstuffs)); }