public ActionResult Create([Bind(Include = "Make, Model, TravelledDistance, Part1, Part2, Part3")] NewCarBindingModel car) { Car newCar = service.AddNewCar(car, db); if (ModelState.IsValid) { db.Cars.Add(newCar); db.SaveChanges(); return(Redirect("/Cars")); } return(View(car)); }
public IActionResult Add(CarsAddVM viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } if (!service.AddNewCar(viewModel)) { return(View(viewModel)); } return(RedirectToAction("ListOfAll", "Cars")); }