public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Price,ImageUrl,CategoryId,ClimateCompensated")] Clothing clothing) { if (id != clothing.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clothing); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClothingExists(clothing.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Set <Category>(), "Id", "Id", clothing.CategoryId); return(View(clothing)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ImageUrl")] Category category) { if (id != category.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }