public async Task <IActionResult> Edit(int id, [Bind("CategoryId,Description")] Category category) { if (id != category.CategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { db.Update(category); await db.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,Description,PurchaseDate,Price,Available,CategoryId")] Product product) { if (id != product.ProductId) { return(NotFound()); } if (ModelState.IsValid) { try { db.Update(product); await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.ProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(db.Category, "CategoryId", "Description", product.CategoryId); return(View(product)); }