public ActionResult Models(AddModelVM model) { var modelRepo = VehicleModelsFactory.GetRepository(); if (ModelState.IsValid) { try { var userId = User.Identity.GetUserId(); var userMgr = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext())); var email = userMgr.FindById(userId).Email; model.NewModel.UserId = userId; model.NewModel.Email = email; modelRepo.Insert(model.NewModel); return(RedirectToAction("Models")); } catch (Exception ex) { throw ex; } } var makeRepo = VehicleMakesFactory.GetRepository(); model.VehicleMakes = makeRepo.GetMakesItems(); model.VehicleModels = modelRepo.GetModelsItems(); return(View("Models", model)); }
public ActionResult AddModel(AddModelVM m) { m.CModel.AddedDate = DateTime.Today; m.CModel.AddedBy = User.Identity.Name; repo.AddModel(m.CModel); return(RedirectToAction("Models", "admin")); }
public ActionResult AddModel() { var makes = repo.GetMakeItems(); var viewmodel = new AddModelVM(); viewmodel.SetMakeItems(makes); return(View(viewmodel)); }
public ActionResult AddModel() { var model = new AddModelVM(); model.CreateList(repo); return(View(model)); }
public ActionResult Models() { var modelRepo = VehicleModelsFactory.GetRepository(); var makeRepo = VehicleMakesFactory.GetRepository(); var model = new AddModelVM() { VehicleModels = modelRepo.GetModelsItems(), VehicleMakes = makeRepo.GetMakesItems(), NewModel = new ModelsItem() }; return(View(model)); }
public ActionResult AddModel(CarModel model) { var repo = CarRepoFactory.Create(); if (ModelState.IsValid) { var newmodel = new AddModelVM(); newmodel.CreateList(repo); return(View(newmodel)); } return(View(model)); }