public async Task <IActionResult> Index(string sortOrder = null, string currentFilter = null, string searchString = null, int?page = null) { ViewData["CurrentSort"] = sortOrder; ViewData["SortValidFrom"] = string.IsNullOrEmpty(sortOrder) ? "validFrom_desc" : ""; ViewData["SortAmount"] = sortOrder == "amount" ? "amount_desc" : "amount"; ViewData["SortDateDue"] = sortOrder == "due" ? "due_desc" : "due"; ViewData["SortCurrency"] = sortOrder == "currency" ? "currency_desc" : "currency"; ViewData["SortMethod"] = sortOrder == "method" ? "method_desc" : "method"; ViewData["SortValidTo"] = sortOrder == "validTo" ? "validTo_desc" : "validTo"; payments.SortOrder = sortOrder != null && sortOrder.EndsWith("_desc") ? SortOrder.Descending : SortOrder.Ascending; payments.SortFunction = getSortFunction(sortOrder); if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; payments.SearchString = searchString; payments.PageIndex = page ?? 1; var l = await payments.GetObjectsList(); return(View(new PaymentViewsList(l))); }