public async Task <IActionResult> Edit(int id, [Bind("CategoryID,CategoryName,Description")] Category category) { if (id != category.CategoryID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductName,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued")] Product product) { if (id != product.ProductId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.ProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(product)); }