// GET: Car/Edit/5 public ActionResult Edit(int id) { var vm = new CarEditVm(); vm.Id = id; vm.CarManufacturerList = new SelectList(carManufacturerService.GetAllCarManufacturers(), "Id", "Manufacturer"); return(View(vm)); }
public ActionResult Edit(CarEditVm vm, int id) { vm.CarManufacturerList = new SelectList(carManufacturerService.GetAllCarManufacturers(), "Id", "Manufacturer"); if (!ModelState.IsValid) { return(View(vm)); } { // TODO: Add update logic here var updatedCar = new CarDetails(); updatedCar.Id = vm.Id; // Might not need updatedCar.ManufacturerId = vm.ManufacturerId; updatedCar.LicensePlate = vm.LicensePlate; updatedCar.Model = vm.Model; updatedCar.Price = vm.Price; updatedCar.HorsePower = vm.HorsePower; updatedCar.Color = vm.Color; carService.UpdateCarDetails(updatedCar); return(RedirectToAction(nameof(Index))); } }