public async Task <IActionResult> Edit(int id, [Bind("CatId,Name,DateOfBirth,ShortDescription,LongDescription,Price,ImageUrl,ImageThumbnailUrl,IsPreferredCat,InStock,CategoryId")] Cat cat) { if (id != cat.CatId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CatExists(cat.CatId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Set <Category>(), "CategoryId", "CategoryName", cat.CategoryId); return(View(cat)); }
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)); }