public ActionResult addVehicle() { ModelMockRepo modelRepo = new ModelMockRepo(); MakeMockRepo makeRepo = new MakeMockRepo(); CarAddViewModel vm = new CarAddViewModel(); vm.Makes = new SelectList(makeRepo.GetAllMakes(), "MakeId", "MakeName"); vm.Models = new SelectList(modelRepo.GetAllModels(), "ModelId", "ModelName"); return(View(vm)); }
public ActionResult Models() { ModelMockRepo modelRepo = new ModelMockRepo(); MakeMockRepo makeRepo = new MakeMockRepo(); ModelViewModel vm = new ModelViewModel(); vm.Models = modelRepo.GetAllModels(); vm.Makes = new SelectList(makeRepo.GetAllMakes(), "MakeId", "MakeName"); return(View(vm)); }
public IHttpActionResult ModelList(int make) { ModelMockRepo repo = new ModelMockRepo(); IEnumerable <Model> found = repo.GetAllModels().Where(m => m.MakeId == make); if (found == null) { return(NotFound()); } return(Ok(found)); }
public ActionResult editVehicle(int id) { ModelMockRepo modelRepo = new ModelMockRepo(); MakeMockRepo makeRepo = new MakeMockRepo(); CarMockRepository carRepo = new CarMockRepository(); CarEditViewModel vm = new CarEditViewModel(); vm.Car = carRepo.GetById(id); vm.Car.Make = makeRepo.GetById(vm.Car.MakeId); vm.Car.Model = modelRepo.GetById(vm.Car.ModelId); vm.Makes = new SelectList(makeRepo.GetAllMakes(), "MakeId", "MakeName"); vm.Models = new SelectList(modelRepo.GetAllModels(), "ModelId", "ModelName"); return(View(vm)); }
public ActionResult addVehicle(CarAddViewModel vm) { if (ModelState.IsValid) { CarMockRepository carRepo = new CarMockRepository(); vm.Car.ImageFileName = vm.ImageUpload.FileName; Car car = carRepo.Create(vm.Car); vm.Car.CarId = car.CarId; return(RedirectToAction("editVehicle/" + vm.Car.CarId)); } ModelMockRepo modelRepo = new ModelMockRepo(); MakeMockRepo makeRepo = new MakeMockRepo(); vm.Makes = new SelectList(makeRepo.GetAllMakes(), "MakeId", "MakeName"); vm.Models = new SelectList(modelRepo.GetAllModels(), "ModelId", "ModelName"); return(View(vm)); }
public ActionResult editVehicle(CarEditViewModel vm) { if (ModelState.IsValid) { CarMockRepository carRepo = new CarMockRepository(); if (vm.ImageUpload != null) { vm.Car.ImageFileName = vm.ImageUpload.FileName; } vm.Car = carRepo.Update(vm.Car); return(RedirectToAction("Vehicles")); } ModelMockRepo modelRepo = new ModelMockRepo(); MakeMockRepo makeRepo = new MakeMockRepo(); vm.Makes = new SelectList(makeRepo.GetAllMakes(), "MakeId", "MakeName"); vm.Models = new SelectList(modelRepo.GetAllModels(), "ModelId", "ModelName"); return(View(vm)); }