public ActionResult OptimizedProcedures1(int?countryId, string sortOrder, string currentFilter, string searchString, int?page) { if (User.IsInRole("Holder")) { return(null); } ViewBag.CountryId = countryId; ViewBag.User = GetCurrentUser(); ViewBag.DocsType = Enum.GetValues(typeof(ProcedureDocsType)); if (searchString != null) { page = 1; } else { searchString = currentFilter; } int pageSize = 5; int pageNumber = (page ?? 1); @ViewBag.CountryId = countryId; ViewBag.CurrentSort = sortOrder; ViewBag.ProcedureTypeSortParm = string.IsNullOrEmpty(sortOrder) ? "ProcedureType_desc" : ""; ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date"; ViewBag.CurrentFilter = searchString; var proc = _procedureService.GetPaginated(countryId, searchString, sortOrder, pageNumber, pageSize, out int totalRecords, out int recordsFiltered); var procedures = Mapper.Map <IEnumerable <ProcedureDTO>, IEnumerable <ProcedureViewModel> >(proc).ToList(); var pagedIst = procedures.ToPagedList(pageNumber, pageSize); var country = _countryService.GetItem((int)countryId); ViewBag.CountryName = country.Name; ViewBag.CountryId = country.Id; return(View("OptimizedProcedures", pagedIst)); }