public ActionResult Index() { var carsFilterViewModel = new CarsFilterViewModel { Impororters = CarRepository.All().Select(x => x.Importer) }; return(View(carsFilterViewModel)); }
public ActionResult List(CarsFilterViewModel filter) { if (ModelState.IsValid) { var carsListViewModel = new CarsListViewModel { Cars = CarRepository.All() .Where(x => (String.IsNullOrEmpty(filter.Importer) || x.Importer == filter.Importer) && (String.IsNullOrEmpty(filter.Description) || x.Description.Contains(filter.Description))) .OrderBy(x => x.YearOfManufacture), SearchedDescription = filter.Description }; return(View(carsListViewModel)); } else { filter.Impororters = CarRepository.All().Select(x => x.Importer); return(View("Index", filter)); } }