예제 #1
0
        public ActionResult Makes()
        {
            MakeMockRepo  makeRepo = new MakeMockRepo();
            MakeViewModel vm       = new MakeViewModel();

            vm.Makes = makeRepo.GetAllMakes();
            return(View(vm));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }