public ActionResult AddModel() { SalesIndexModelsVM VM = new SalesIndexModelsVM(); var models = new VehicleModelRepositoryADO(); var makeRepo = new MakeRepositoryADO(); VM.SetAvailableMakes(makeRepo.ReadAllMakes()); VM.Models = models.ReadAllModel(); return(View(VM)); }
public ActionResult AddModel(SalesIndexModelsCM form) { if (ModelState.IsValid) { VehicleModels model = new VehicleModels(); var repo = new VehicleModelRepositoryADO(); model.Model = form.Model; model.Make = form.Make; model.DateAdded = form.DateAdded; model.EmployeeId = form.EmployeeId; repo.CreateModel(model); return(RedirectToAction("Index")); } else { SalesIndexModelsVM VM = new SalesIndexModelsVM(); var models = new VehicleModelRepositoryADO(); VM.Models = models.ReadAllModel(); VM.Form = form; return(View(VM)); } }