public async Task <IActionResult> Edit(int id, [Bind("CarBrandID,CarBrandName")] CarBrand carBrand) { if (id != carBrand.CarBrandID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(carBrand); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarBrandExists(carBrand.CarBrandID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(carBrand)); }
public async Task <IActionResult> Edit(int id, [Bind("CarModelID,CarBrandFK,CarModelName")] CarModel carModel) { if (id != carModel.CarModelID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(carModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarModelExists(carModel.CarModelID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CarBrandFK"] = new SelectList(_context.CarBrand, "CarBrandID", "CarBrandName", carModel.CarBrandFK); return(View(carModel)); }