public async Task <IActionResult> Edit(int id, [Bind("CarModelId,Manufacturer,Model,AddInformations")] 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))); } return(View(carModel)); }
public async Task <IActionResult> Edit(int id, [Bind("CarId,ProductionYear,Mileage,AccidentFree,Price,Discount,CarModelId")] Car car) { if (id != car.CarId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(car); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(car.CarId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CarModelId"] = new SelectList(_context.CarModels, "CarModelId", "Manufacturer", car.CarModelId); return(View(car)); }