public async Task <IActionResult> Index(string titleFilter, string cityFilter, string productState, AdIndexViewModel model, int page = 1) { int pageSize = 5; var result = await _adService.GetActiveAds(); if (!result.Succedeed) { return(View(model)); } var topAds = await _adService.GetActiveRandomTopAds(); List <AdDTO> adQueryResult = result.Property; adQueryResult = await _adFilter.FilteringData(titleFilter, productState, adQueryResult, model); model = await _adFilter.PrepearingFilter(adQueryResult, model); if (topAds.Property.Count() > 0) { model.TopAds = topAds.Property.ToList(); } int count = model.SimpleAds.Count(); PageViewModel pageViewModel = new PageViewModel(count, page, pageSize); model.PageViewModel = pageViewModel; model.SimpleAds = model.SimpleAds.Skip((page - 1) * pageSize).Take(pageSize).ToList(); return(View(model)); }