public ActionResult purchase(int id)
        {
            CarMockRepository    carRepo   = new CarMockRepository();
            MakeMockRepo         makeRepo  = new MakeMockRepo();
            ModelMockRepo        modelRepo = new ModelMockRepo();
            PurchaseCarViewModel vm        = new PurchaseCarViewModel();

            vm.Car       = carRepo.GetById(id);
            vm.Car.Make  = makeRepo.GetById(vm.Car.MakeId);
            vm.Car.Model = modelRepo.GetById(vm.Car.ModelId);
            return(View(vm));
        }
Пример #2
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));
        }
Пример #3
0
        public ActionResult Index()
        {
            SpecialMockRepo       specialRepo = new SpecialMockRepo();
            FeaturedCarsViewModel vm          = new FeaturedCarsViewModel();
            CarMockRepository     carRepo     = new CarMockRepository();

            vm.Specials     = specialRepo.GetAllSpecials();
            vm.FeaturedCars = carRepo.GetAllCars().Where(m => m.isFeatured == true);
            MakeMockRepo  makeRepo  = new MakeMockRepo();
            ModelMockRepo modelRepo = new ModelMockRepo();

            foreach (var car in vm.FeaturedCars)
            {
                car.Make  = makeRepo.GetById(car.MakeId);
                car.Model = modelRepo.GetById(car.ModelId);
            }
            return(View(vm));
        }
        public ActionResult Inventory()
        {
            CarInventoryViewModel inventoryViewModel = new CarInventoryViewModel();
            CarMockRepository     carMock            = new CarMockRepository();
            MakeMockRepo          makeRepo           = new MakeMockRepo();
            ModelMockRepo         modelRepo          = new ModelMockRepo();

            IEnumerable <Car> allCars = carMock.GetAllCars();

            foreach (Car item in allCars)
            {
                item.Make  = makeRepo.GetById(item.MakeId);
                item.Model = modelRepo.GetById(item.ModelId);
            }

            IEnumerable <Car> newVehicles  = allCars.Where(v => v.Type == "New");
            IEnumerable <Car> usedVehicles = allCars.Where(v => v.Type == "Used");

            inventoryViewModel.UsedInventory = Inventory(usedVehicles);
            inventoryViewModel.NewInventory  = Inventory(newVehicles);
            return(View(inventoryViewModel));
        }