public IActionResult Index(SortState sortState, int page = 1) { CarsFilterViewModel filter = HttpContext.Session.Get <CarsFilterViewModel>(filterKey); if (filter == null) { filter = new CarsFilterViewModel { CarEngineNum = default, CarIssueDate = default, CarPrice = default, CarRegNum = default, CarRentalPrice = default, CarVINcode = string.Empty
public ActionResult Index() { var carsFilterViewModel = new CarsFilterViewModel { Impororters = CarRepository.All().Select(x => x.Importer) }; return(View(carsFilterViewModel)); }
// GET: Cars public ActionResult Index(int?page, CarsFilterViewModel filter) { var cars = filter.GetFilterResult(); ViewBag.Brands = filter.Brands; ViewBag.Makers = filter.Makers; ViewBag.Maker = filter.MakerId; ViewBag.Brand = filter.BrandId; ViewBag.Sort = filter.Sort; ViewBag.SortList = filter.SortList; ViewBag.Filter = (CarsFilterViewModel)filter.Clone(); return(View(cars.ToList().ToPagedList(page ?? 1, 4))); }
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)); } }