public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info,Cost,Year,FormId,MaterialId,TypeId,BrandId")] Guitars guitars) { if (id != guitars.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(guitars); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GuitarsExists(guitars.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BrandId"] = new SelectList(_context.Brands, "Id", "Name", guitars.BrandId); ViewData["FormId"] = new SelectList(_context.Forms, "Id", "Name", guitars.FormId); ViewData["MaterialId"] = new SelectList(_context.Materials, "Id", "Name", guitars.MaterialId); ViewData["TypeId"] = new SelectList(_context.Types, "Id", "Name", guitars.TypeId); return(View(guitars)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Types types) { if (id != types.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(types); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypesExists(types.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(types)); }