public async Task <IActionResult> Index(string SortOrder, string Search, string BINFilter, string NameKKFilter, string NameRUFilter, DateTime?DateRegisterFilter, string OKEDFilter, string ActivityKindKKFilter, string ActivityKindRUFilter, string OKEDSecondaryFilter, string KRPFilter, string KRPNameKKFilter, string KRPNameRUFilter, string CATOFilter, string LocalityKKFilter, string LocalityRUFilter, string LegalAddressFilter, string HeadNameFilter, int?PageSize, int?Page) { List <CompanyKK> companiesKK = new List <CompanyKK>(); ViewBag.BINFilter = BINFilter; ViewBag.NameKKFilter = NameKKFilter; ViewBag.NameRUFilter = NameRUFilter; ViewBag.DateRegisterFilter = DateRegisterFilter; ViewBag.OKEDFilter = OKEDFilter; ViewBag.ActivityKindKKFilter = ActivityKindKKFilter; ViewBag.ActivityKindRUFilter = ActivityKindRUFilter; ViewBag.OKEDSecondaryFilter = OKEDSecondaryFilter; ViewBag.KRPFilter = KRPFilter; ViewBag.KRPNameKKFilter = KRPNameKKFilter; ViewBag.KRPNameRUFilter = KRPNameRUFilter; ViewBag.CATOFilter = CATOFilter; ViewBag.LocalityKKFilter = LocalityKKFilter; ViewBag.LocalityRUFilter = LocalityRUFilter; ViewBag.LegalAddressFilter = LegalAddressFilter; ViewBag.HeadNameFilter = HeadNameFilter; ViewBag.BINSort = SortOrder == "BIN" ? "BINDesc" : "BIN"; ViewBag.NameKKSort = SortOrder == "NameKK" ? "NameKKDesc" : "NameKK"; ViewBag.NameRUSort = SortOrder == "NameRU" ? "NameRUDesc" : "NameRU"; ViewBag.DateRegisterSort = SortOrder == "DateRegister" ? "DateRegisterDesc" : "DateRegister"; ViewBag.OKEDSort = SortOrder == "OKED" ? "OKEDDesc" : "OKED"; ViewBag.ActivityKindKKSort = SortOrder == "ActivityKindKK" ? "ActivityKindKKDesc" : "ActivityKindKK"; ViewBag.ActivityKindRUSort = SortOrder == "ActivityKindRU" ? "ActivityKindRUDesc" : "ActivityKindRU"; ViewBag.OKEDSecondarySort = SortOrder == "OKEDSecondary" ? "OKEDSecondaryDesc" : "OKEDSecondary"; ViewBag.KRPSort = SortOrder == "KRP" ? "KRPDesc" : "KRP"; ViewBag.KRPNameKKSort = SortOrder == "KRPNameKK" ? "KRPNameKKDesc" : "KRPNameKK"; ViewBag.KRPNameRUSort = SortOrder == "KRPNameRU" ? "KRPNameRUDesc" : "KRPNameRU"; ViewBag.CATOSort = SortOrder == "CATO" ? "CATODesc" : "CATO"; ViewBag.LocalityKKSort = SortOrder == "LocalityKK" ? "LocalityKKDesc" : "LocalityKK"; ViewBag.LocalityRUSort = SortOrder == "LocalityRU" ? "LocalityRUDesc" : "LocalityRU"; ViewBag.LegalAddressSort = SortOrder == "LegalAddress" ? "LegalAddressDesc" : "LegalAddress"; ViewBag.HeadNameSort = SortOrder == "HeadName" ? "HeadNameDesc" : "HeadName"; string url = "api/CompaniesKK", route = "", routeCount = ""; if (!string.IsNullOrEmpty(SortOrder)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"SortOrder={SortOrder}"; } if (!string.IsNullOrEmpty(Search)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Search={Search}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"Search={Search}"; } if (!string.IsNullOrEmpty(BINFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"BIN={BINFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"BIN={BINFilter}"; } if (!string.IsNullOrEmpty(NameKKFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"NameKK={NameKKFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"NameKK={NameKKFilter}"; } if (!string.IsNullOrEmpty(NameRUFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"NameRU={NameRUFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"NameRU={NameRUFilter}"; } if (DateRegisterFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"DateRegister={DateRegisterFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"DateRegister={DateRegisterFilter.ToString()}"; } if (!string.IsNullOrEmpty(OKEDFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"OKED={OKEDFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"OKED={OKEDFilter}"; } if (!string.IsNullOrEmpty(ActivityKindKKFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"ActivityKindKK={ActivityKindKKFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"ActivityKindKK={ActivityKindKKFilter}"; } if (!string.IsNullOrEmpty(ActivityKindRUFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"ActivityKindRU={ActivityKindRUFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"ActivityKindRU={ActivityKindRUFilter}"; } if (!string.IsNullOrEmpty(OKEDSecondaryFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"OKEDSecondary={OKEDSecondaryFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"OKEDSecondary={OKEDSecondaryFilter}"; } if (!string.IsNullOrEmpty(KRPFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"KRP={KRPFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"KRP={KRPFilter}"; } if (!string.IsNullOrEmpty(KRPNameKKFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"KRPNameKK={KRPNameKKFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"KRPNameKK={KRPNameKKFilter}"; } if (!string.IsNullOrEmpty(KRPNameRUFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"KRPNameRU={KRPNameRUFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"KRPNameRU={KRPNameRUFilter}"; } if (!string.IsNullOrEmpty(CATOFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"CATO={CATOFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"CATO={CATOFilter}"; } if (!string.IsNullOrEmpty(LocalityKKFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"LocalityKK={LocalityKKFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"LocalityKK={LocalityKKFilter}"; } if (!string.IsNullOrEmpty(LocalityRUFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"LocalityRU={LocalityRUFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"LocalityRU={LocalityRUFilter}"; } if (!string.IsNullOrEmpty(LegalAddressFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"LegalAddress={LegalAddressFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"LegalAddress={LegalAddressFilter}"; } if (!string.IsNullOrEmpty(HeadNameFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"HeadName={HeadNameFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"HeadName={HeadNameFilter}"; } IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList"); var pageSizeList = pageSizeListSection.AsEnumerable(); ViewBag.PageSizeList = new SelectList(pageSizeList.OrderBy(p => p.Key) .Select(p => { return(new KeyValuePair <string, string>(p.Value ?? "0", p.Value)); }), "Key", "Value"); if (PageSize == null) { PageSize = Convert.ToInt32(pageSizeList.Min(p => p.Value)); } if (PageSize == 0) { PageSize = null; } if (PageSize != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"PageSize={PageSize.ToString()}"; if (Page == null) { Page = 1; } } if (Page != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Page={Page.ToString()}"; } HttpResponseMessage response = await _HttpApiClient.GetAsync(url + route), responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount); if (response.IsSuccessStatusCode) { companiesKK = await response.Content.ReadAsAsync <List <CompanyKK> >(); } int companiesKKCount = 0; if (responseCount.IsSuccessStatusCode) { companiesKKCount = await responseCount.Content.ReadAsAsync <int>(); } ViewBag.Search = Search; ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.Page = Page != null ? (int)Page : 1; ViewBag.TotalPages = PageSize != null ? (int)(Math.Ceiling((decimal)companiesKKCount / (decimal)PageSize)) : 1; ViewBag.StartPage = Page - 5; ViewBag.EndPage = Page + 4; if (ViewBag.StartPage <= 0) { ViewBag.EndPage -= (ViewBag.StartPage - 1); ViewBag.StartPage = 1; } if (ViewBag.EndPage > ViewBag.TotalPages) { ViewBag.EndPage = ViewBag.TotalPages; if (ViewBag.EndPage > 10) { ViewBag.StartPage = ViewBag.EndPage - 9; } } return(View(companiesKK)); }
public async Task <IActionResult> Index(string SortOrder, int?EgovIdFilter, string CodeFilter, string NameKKFilter, string NameRUFilter, int?ParentFilter, int?AreaTypeFilter, int?PageSize, int?Page) { List <CATO> catoes = new List <CATO>(); ViewBag.EgovIdFilter = EgovIdFilter; ViewBag.CodeFilter = CodeFilter; ViewBag.NameKKFilter = NameKKFilter; ViewBag.NameRUFilter = NameRUFilter; ViewBag.ParentFilter = ParentFilter; ViewBag.AreaTypeFilter = AreaTypeFilter; ViewBag.EgovIdSort = SortOrder == "EgovId" ? "EgovIdDesc" : "EgovId"; ViewBag.CodeSort = SortOrder == "Code" ? "CodeDesc" : "Code"; ViewBag.NameKKSort = SortOrder == "NameKK" ? "NameKKDesc" : "NameKK"; ViewBag.NameRUSort = SortOrder == "NameRU" ? "NameRUDesc" : "NameRU"; ViewBag.NameENSort = SortOrder == "NameEN" ? "NameENDesc" : "NameEN"; ViewBag.ParentSort = SortOrder == "Parent" ? "ParentDesc" : "Parent"; ViewBag.AreaTypeSort = SortOrder == "AreaType" ? "AreaTypeDesc" : "AreaType"; string url = "api/CATO", route = "", routeCount = ""; if (!string.IsNullOrEmpty(SortOrder)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"SortOrder={SortOrder}"; } if (EgovIdFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"EgovIdFilter={EgovIdFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"EgovIdFilter={EgovIdFilter.ToString()}"; } if (!string.IsNullOrEmpty(CodeFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"CodeFilter={CodeFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"CodeFilter={CodeFilter}"; } if (!string.IsNullOrEmpty(NameKKFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"NameKKFilter={NameKKFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"NameKKFilter={NameKKFilter}"; } if (!string.IsNullOrEmpty(NameRUFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"NameRUFilter={NameRUFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"NameRUFilter={NameRUFilter}"; } if (ParentFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"ParentFilter={ParentFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"ParentFilter={ParentFilter.ToString()}"; } if (AreaTypeFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"AreaTypeFilter={AreaTypeFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"AreaTypeFilter={AreaTypeFilter.ToString()}"; } IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList"); var pageSizeList = pageSizeListSection.AsEnumerable(); ViewBag.PageSizeList = new SelectList(pageSizeList.OrderBy(p => p.Key), "Value", "Value"); if (PageSize == null) { PageSize = Convert.ToInt32(pageSizeList.Min(p => p.Value)); } if (PageSize != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"PageSize={PageSize.ToString()}"; if (Page == null) { Page = 1; } } if (Page != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Page={Page.ToString()}"; } HttpResponseMessage response = await _HttpApiClient.GetAsync(url + route), responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount); if (response.IsSuccessStatusCode) { catoes = await response.Content.ReadAsAsync <List <CATO> >(); } int catoesCount = 0; if (responseCount.IsSuccessStatusCode) { catoesCount = await responseCount.Content.ReadAsAsync <int>(); } ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.Page = Page != null ? (int)Page : 1; ViewBag.TotalPages = PageSize != null ? (int)(Math.Ceiling((decimal)catoesCount / (decimal)PageSize)) : 1; ViewBag.StartPage = Page - 5; ViewBag.EndPage = Page + 4; if (ViewBag.StartPage <= 0) { ViewBag.EndPage -= (ViewBag.StartPage - 1); ViewBag.StartPage = 1; } if (ViewBag.EndPage > ViewBag.TotalPages) { ViewBag.EndPage = ViewBag.TotalPages; if (ViewBag.EndPage > 10) { ViewBag.StartPage = ViewBag.EndPage - 9; } } return(View(catoes)); }
public async Task <IActionResult> Index(string SortOrder, string NameFilter, string NumberCASFilter, string FormulaFilter, decimal?MaximumPermissibleConcentrationOneTimeMaximumFilter, decimal?MaximumPermissibleConcentrationDailyAverageFilter, int?HazardClassFilter, int?CodeFilter, decimal?ApproximateSafeExposureLevelFilter, int?PageSize, int?Page) { List <AirContaminantKK> airContaminantsKK = new List <AirContaminantKK>(); ViewBag.NameFilter = NameFilter; ViewBag.NumberCASFilter = NumberCASFilter; ViewBag.FormulaFilter = FormulaFilter; ViewBag.MaximumPermissibleConcentrationOneTimeMaximumFilter = MaximumPermissibleConcentrationOneTimeMaximumFilter; ViewBag.MaximumPermissibleConcentrationDailyAverageFilter = MaximumPermissibleConcentrationDailyAverageFilter; ViewBag.HazardClassFilter = HazardClassFilter; ViewBag.CodeFilter = CodeFilter; ViewBag.ApproximateSafeExposureLevelFilter = ApproximateSafeExposureLevelFilter; ViewBag.NameSort = SortOrder == "Name" ? "NameDesc" : "Name"; ViewBag.NumberCASSort = SortOrder == "NumberCAS" ? "NumberCASDesc" : "NumberCAS"; ViewBag.FormulaSort = SortOrder == "Formula" ? "FormulaDesc" : "Formula"; ViewBag.MaximumPermissibleConcentrationOneTimeMaximumSort = SortOrder == "MaximumPermissibleConcentrationOneTimeMaximum" ? "MaximumPermissibleConcentrationOneTimeMaximumDesc" : "MaximumPermissibleConcentrationOneTimeMaximum"; ViewBag.MaximumPermissibleConcentrationDailyAverageSort = SortOrder == "MaximumPermissibleConcentrationDailyAverage" ? "MaximumPermissibleConcentrationDailyAverageDesc" : "MaximumPermissibleConcentrationDailyAverage"; ViewBag.HazardClassSort = SortOrder == "HazardClass" ? "HazardClassDesc" : "HazardClass"; ViewBag.CodeSort = SortOrder == "Code" ? "CodeDesc" : "Code"; ViewBag.ApproximateSafeExposureLevelSort = SortOrder == "ApproximateSafeExposureLevel" ? "ApproximateSafeExposureLevelDesc" : "ApproximateSafeExposureLevel"; string url = "api/AirContaminantsKK", route = "", routeCount = ""; if (!string.IsNullOrEmpty(SortOrder)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"SortOrder={SortOrder}"; } if (!string.IsNullOrEmpty(NameFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Name={NameFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"Name={NameFilter}"; } if (!string.IsNullOrEmpty(NumberCASFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"NumberCAS={NumberCASFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"NumberCAS={NumberCASFilter}"; } if (!string.IsNullOrEmpty(FormulaFilter)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Formula={FormulaFilter}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"Formula={FormulaFilter}"; } if (MaximumPermissibleConcentrationOneTimeMaximumFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"MaximumPermissibleConcentrationOneTimeMaximum={MaximumPermissibleConcentrationOneTimeMaximumFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"MaximumPermissibleConcentrationOneTimeMaximum={MaximumPermissibleConcentrationOneTimeMaximumFilter.ToString()}"; } if (MaximumPermissibleConcentrationDailyAverageFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"MaximumPermissibleConcentrationDailyAverage={MaximumPermissibleConcentrationDailyAverageFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"MaximumPermissibleConcentrationDailyAverage={MaximumPermissibleConcentrationDailyAverageFilter.ToString()}"; } if (HazardClassFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"HazardClass={HazardClassFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"HazardClass={HazardClassFilter.ToString()}"; } if (CodeFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Code={CodeFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"Code={CodeFilter.ToString()}"; } if (ApproximateSafeExposureLevelFilter != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"ApproximateSafeExposureLevel={ApproximateSafeExposureLevelFilter.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"ApproximateSafeExposureLevel={ApproximateSafeExposureLevelFilter.ToString()}"; } IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList"); var pageSizeList = pageSizeListSection.AsEnumerable(); ViewBag.PageSizeList = new SelectList(pageSizeList.OrderBy(p => p.Key) .Select(p => { return(new KeyValuePair <string, string>(p.Value ?? "0", p.Value)); }), "Key", "Value"); if (PageSize == null) { PageSize = Convert.ToInt32(pageSizeList.Min(p => p.Value)); } if (PageSize == 0) { PageSize = null; } if (PageSize != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"PageSize={PageSize.ToString()}"; if (Page == null) { Page = 1; } } if (Page != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Page={Page.ToString()}"; } HttpResponseMessage response = await _HttpApiClient.GetAsync(url + route), responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount); if (response.IsSuccessStatusCode) { airContaminantsKK = await response.Content.ReadAsAsync <List <AirContaminantKK> >(); } int airContaminantsKKCount = 0; if (responseCount.IsSuccessStatusCode) { airContaminantsKKCount = await responseCount.Content.ReadAsAsync <int>(); } ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.Page = Page != null ? (int)Page : 1; ViewBag.TotalPages = PageSize != null ? (int)(Math.Ceiling((decimal)airContaminantsKKCount / (decimal)PageSize)) : 1; ViewBag.StartPage = Page - 5; ViewBag.EndPage = Page + 4; if (ViewBag.StartPage <= 0) { ViewBag.EndPage -= (ViewBag.StartPage - 1); ViewBag.StartPage = 1; } if (ViewBag.EndPage > ViewBag.TotalPages) { ViewBag.EndPage = ViewBag.TotalPages; if (ViewBag.EndPage > 10) { ViewBag.StartPage = ViewBag.EndPage - 9; } } return(View(airContaminantsKK)); }
public async Task <IActionResult> Index(string SortOrder, string Name, string NumberCAS, int?HazardClass, int?PageSize, int?Page) { List <AirContaminant> airContaminants = new List <AirContaminant>(); ViewBag.NameFilter = Name; ViewBag.NumberCASFilter = NumberCAS; ViewBag.HazardClassFilter = HazardClass; ViewBag.NameSort = SortOrder == "Name" ? "NameDesc" : "Name"; ViewBag.NumberCASSort = SortOrder == "NumberCAS" ? "NumberCASDesc" : "NumberCAS"; ViewBag.HazardClassSort = SortOrder == "HazardClass" ? "HazardClassDesc" : "HazardClass"; string url = "api/AirContaminants", route = "", routeCount = ""; if (!string.IsNullOrEmpty(SortOrder)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"SortOrder={SortOrder}"; } if (!string.IsNullOrEmpty(Name)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Name={Name}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"Name={Name}"; } if (!string.IsNullOrEmpty(NumberCAS)) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"NumberCAS={NumberCAS}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"NumberCAS={NumberCAS}"; } if (HazardClass != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"HazardClass={HazardClass.ToString()}"; routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&"; routeCount += $"HazardClass={HazardClass.ToString()}"; } if (PageSize != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"PageSize={PageSize.ToString()}"; if (Page == null) { Page = 1; } } if (Page != null) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Page={Page.ToString()}"; } HttpResponseMessage response = await _HttpApiClient.GetAsync(url + route), responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount); if (response.IsSuccessStatusCode) { airContaminants = await response.Content.ReadAsAsync <List <AirContaminant> >(); } int airContaminantsCount = 0; if (responseCount.IsSuccessStatusCode) { airContaminantsCount = await responseCount.Content.ReadAsAsync <int>(); } ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.Page = Page != null ? (int)Page : 1; ViewBag.TotalPages = PageSize != null ? (int)(Math.Ceiling((decimal)airContaminantsCount / (decimal)PageSize)) : 1; ViewBag.StartPage = Page - 5; ViewBag.EndPage = Page + 4; if (ViewBag.StartPage <= 0) { ViewBag.EndPage -= (ViewBag.StartPage - 1); ViewBag.StartPage = 1; } if (ViewBag.EndPage > ViewBag.TotalPages) { ViewBag.EndPage = ViewBag.TotalPages; if (ViewBag.EndPage > 10) { ViewBag.StartPage = ViewBag.EndPage - 9; } } IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList"); var pageSizeList = pageSizeListSection.AsEnumerable(); ViewBag.PageSizeList = new SelectList(pageSizeList.OrderBy(p => p.Key), "Value", "Value"); return(View(airContaminants)); }