public ActionResult Cars(CarsViewModel vm) { Debug.WriteLine(vm.minKM); Debug.WriteLine(vm.maxKM); Debug.WriteLine(vm.minPrice); Debug.WriteLine(vm.maxPrice); List <tblCars> cars = new List <tblCars>(); tblCarsService service = new tblCarsService(); tblColorsService colservice = new tblColorsService(); tblBrandsService bservice = new tblBrandsService(); cars = service.getAllCars().ToList(); if (vm.selectedBrandId != 0) { cars = service.FilterByBrand(cars, bservice.getBrands().ElementAt(vm.selectedBrandId - 2)).ToList(); Debug.WriteLine(cars.Count()); } if (vm.selectedColorId != 0) { cars = service.FilterByColor(cars, colservice.getColors().ElementAt(vm.selectedColorId - 1)).ToList(); Debug.WriteLine(cars.Count()); } if (vm.transmissionChoice == Transmission.Automaat || vm.transmissionChoice == Transmission.Manueel) { cars = cars.Where(a => a.Transmission == vm.transmissionChoice.ToString()).ToList(); Debug.WriteLine(cars.Count()); } if (vm.fuelChoice == Fuel.Benzine || vm.fuelChoice == Fuel.Diesel || vm.fuelChoice == Fuel.Elektrisch || vm.fuelChoice == Fuel.Hybride || vm.fuelChoice == Fuel.LPG) { cars = cars.Where(a => a.CarFuel == vm.fuelChoice.ToString()).ToList(); Debug.WriteLine(cars.Count()); } cars = service.FilterByKM(cars, vm.minKM, vm.maxKM).ToList(); Debug.WriteLine(cars.Count()); cars = service.FilterByPrice(cars, Convert.ToInt32(vm.minPrice), Convert.ToInt32(vm.maxPrice)).ToList(); Debug.WriteLine(cars.Count()); vm.cars = cars; vm.minKM = service.getAllCars().Min(a => a.CarKilometers); vm.maxKM = service.getAllCars().Max(a => a.CarKilometers); vm.minPrice = service.getAllCars().Min(b => b.CarPrice); vm.maxPrice = service.getAllCars().Max(b => b.CarPrice); vm.brandChoice = bservice.getBrands(); vm.colorChoice = colservice.getColors(); vm.images = service.getAllImages(); vm.CarsInStock = service.getAllCars().Where(a => a.Sold == 0).Count(); return(View(vm)); }
public ActionResult AddBrand() { tblBrandsService service = new tblBrandsService(); AddBrandViewModel vm = new AddBrandViewModel(); vm.brands = service.getBrands(); return(View(vm)); }
public ActionResult AddCar() { AddCarViewModel vm = new AddCarViewModel(); tblCarsService cservice = new tblCarsService(); tblColorsService colservice = new tblColorsService(); tblBrandsService bservice = new tblBrandsService(); vm.brandChoice = bservice.getBrands(); vm.colorChoice = colservice.getColors(); return(View(vm)); }
public ActionResult EditCar(int carID) { EditCarViewModel vm = new EditCarViewModel(); tblCarsService cservice = new tblCarsService(); tblColorsService colservice = new tblColorsService(); tblBrandsService bservice = new tblBrandsService(); vm.car = cservice.getCar(carID); vm.selectedBrandId = vm.car.BrandID; vm.selectedColorId = vm.car.ColorID; vm.brandChoice = bservice.getBrands(); vm.colorChoice = colservice.getColors(); vm.fuelChoice = (Fuel)Enum.Parse(typeof(Fuel), vm.car.CarFuel, true); vm.transmissionChoice = (Transmission)Enum.Parse(typeof(Transmission), vm.car.Transmission, true); return(View(vm)); }
public ActionResult Cars() { CarsViewModel vm = new CarsViewModel(); tblCarsService service = new tblCarsService(); tblColorsService colservice = new tblColorsService(); tblBrandsService bservice = new tblBrandsService(); vm.cars = service.getAllCars(); if (vm.cars.Count() > 0) { vm.minKM = service.getAllCars().Min(a => a.CarKilometers); vm.maxKM = service.getAllCars().Max(a => a.CarKilometers); vm.minPrice = service.getAllCars().Min(b => b.CarPrice); vm.maxPrice = service.getAllCars().Max(b => b.CarPrice); vm.brandChoice = bservice.getBrands(); vm.colorChoice = colservice.getColors(); vm.images = service.GetFrontImages(); vm.CarsInStock = service.getAllCars().Where(a => a.Sold == 0).Count(); } return(View(vm)); }