//public IActionResult Edit(int Id) //{ // var model = _db.FindCarById(Id); // if (model == null) // { // return RedirectToAction("Not Found"); // } // return View(model); //} public IActionResult Edit(Car car) { //var model = _db.FindCarById(Id); if (ModelState.IsValid) { _db.Update(car); return(RedirectToAction("Details", new { id = car.Id })); } return(View(car)); }
public async Task <ActionResult> Edit(CarViewModel carViewModel) { if (ModelState.IsValid) { var car = carViewModel.ToEntityModel(); await db.Update(car); TempData["Message"] = "You have saved the car!"; return(RedirectToAction("Index")); } return(View(carViewModel)); }