public async Task <ActionResult> Search(HomepageAdVM homeModel) { var modelVM = await _adRepo.GetSearchResults(homeModel.Search); var model = _mapper.Map <List <Ad> >(modelVM); return(View(nameof(Index), model)); }
public async Task <IActionResult> Index() { var model = new HomepageAdVM(); var ads = await _repo.FindAll(); var year = _repo.GetYearList(); var price = _repo.GetPriceList(); var makeItems = await _makeRepo.GetSelectListItem(); var modelItems = await _modelRepo.GetSelectListItem(); var fuelTypeItems = await _fuelTypeRepo.GetSelectListItem(); var bodyTypeItems = await _bodyTypeRepo.GetSelectListItem(); var damageItems = await _damageRepo.GetSelectListItem(); var colorItems = await _colorRepo.GetSelectListItem(); var gearBoxItems = await _gearBoxRepo.GetSelectListItem(); var yearItems = year.Select(q => new SelectListItem { Text = q.ToString(), Value = q.ToString() }); var priceItems = price.Select(q => new SelectListItem { Text = q.ToString(), Value = q.ToString() }); var search = new SearchAdVM { MakeList = makeItems, ModelList = modelItems, YearFrom = yearItems, YearTo = yearItems, PriceFrom = priceItems, PriceTo = priceItems, FuelTypeList = fuelTypeItems, BodyTypeList = bodyTypeItems, DamageList = damageItems, ColorList = colorItems, GearBoxList = gearBoxItems }; model.Ads = ads; model.Search = search; return(View(model)); }