public async Task <IActionResult> Index(string sort, string search, int?pageNumber) { ViewData["CurrentSort"] = sort; ViewData["SortByTitle"] = sort == "title" ? "title_desc" : "title"; ViewData["SortByAuthor"] = sort == "author" ? "author_desc" : "author"; ViewData["SortByIndustry"] = sort == "industry" ? "industry_desc" : "industry"; ViewData["SortByDate"] = sort == "newest" ? "oldest" : "newest"; ViewData["SortByDownloads"] = sort == "downloads" ? "downloads_asc" : "downloads"; if (search != null) { pageNumber = 1; } ViewData["Search"] = search; var reports = await _reportServices.GetPendingReports(sort, search); ViewData["ResultsCount"] = reports.Count; var pageSize = 8; return(View(await reports.ToPagedListAsync(pageNumber ?? 1, pageSize))); }