public ActionResult EditCar(CarAddEdditVM model) { CarComponentRepoADO repo = new CarComponentRepoADO(); CarRepoADO repoc = new CarRepoADO(); if (model.UploadedFile != null && model.UploadedFile.ContentLength > 0) { if (model.UploadedFile.ContentType == "image/jpeg" || model.UploadedFile.ContentType == "image/png") { string path = Path.Combine(Server.MapPath("~/Uploads"), Path.GetFileName(model.UploadedFile.FileName)); model.UploadedFile.SaveAs(path); model.AddCar.ImageFileName = model.UploadedFile.FileName; } else { ModelState.AddModelError("UploadedFile", "The uploaded file must be of type .jpg or .png"); } } if (!ModelState.IsValid) { model.SetSelectList(repo.GetModels(), repo.GetMakes(), repo.GetColors(), repo.GetInteriors(), repo.GetBodies(), repo.GetTrans()); return(View("editcar", model)); } repoc.EditCar(model.AddCar); SalesIndexVM indexvm = new SalesIndexVM(); indexvm.Inventory = repoc.GetInventory(); return(RedirectToAction("index", indexvm)); }
public ActionResult Index(VehicleSearchCM form) { if (ModelState.IsValid) { SalesIndexVM VM = new SalesIndexVM(); var repo = new VehicleRepositoryADO(); VM.Vehicles = repo.Search(form, null); VM.SetYear(); VM.SetPrice(); VM.Form = form; return(View(VM)); } else { SalesIndexVM VM = new SalesIndexVM(); var repo = new VehicleRepositoryADO(); VM.Vehicles = repo.Search(form, null); VM.SetYear(); VM.SetPrice(); VM.Form = form; return(View(VM)); } }
// GET: Admin public ActionResult Index() { CarRepoADO repoC = new CarRepoADO(); SalesIndexVM model = new SalesIndexVM(); model.Inventory = repoC.GetInventory(); return(View(model)); }
public ActionResult New() { SalesIndexVM model = new SalesIndexVM(); CarRepoADO repo = new CarRepoADO(); model.Inventory = repo.GetInventory().Where(c => c.IsNew == true).ToList(); return(View(model)); }
public ActionResult Index() { SalesIndexVM VM = new SalesIndexVM(); var repo = new VehicleRepositoryADO(); VehicleSearchCM form = new VehicleSearchCM(); VM.Vehicles = repo.Search(form, null); VM.SetYear(); VM.SetPrice(); return(View(VM)); }