Example #1
0
        public async Task <IActionResult> Index()
        {
            HttpResponseMessage response = await _HttpApiClient.GetAsync("api/Account/GetAuthenticated");

            string OutputViewText = await response.Content.ReadAsStringAsync();

            OutputViewText = OutputViewText.Replace("\"", "");
            if (Convert.ToBoolean(OutputViewText) == true)
            {
                return(View());
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Example #2
0
        // GET: LEDScreens
        public async Task <IActionResult> Index(string SortOrder,
                                                string NameFilter,
                                                int?MonitoringPostIdFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <LEDScreen> ledScreens = new List <LEDScreen>();

            ViewBag.NameFilter             = NameFilter;
            ViewBag.MonitoringPostIdFilter = MonitoringPostIdFilter;

            ViewBag.NameSort           = SortOrder == "Name" ? "NameDesc" : "Name";
            ViewBag.MonitoringPostSort = SortOrder == "MonitoringPost" ? "MonitoringPostDesc" : "MonitoringPost";

            string url        = "api/LEDScreens",
                   route      = "",
                   routeCount = "";

            if (!string.IsNullOrEmpty(SortOrder))
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"SortOrder={SortOrder}";
            }
            if (NameFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"Name={NameFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"Name={NameFilter}";
            }
            if (MonitoringPostIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"MonitoringPostId={MonitoringPostIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"MonitoringPostId={MonitoringPostIdFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                ledScreens = await response.Content.ReadAsAsync <List <LEDScreen> >();
            }
            int ledScreenCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                ledScreenCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(ledScreenCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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;
                }
            }

            List <MonitoringPost> monitoringPosts       = new List <MonitoringPost>();
            string urlMonitoringPosts                   = "api/MonitoringPosts",
                   routeMonitoringPosts                 = "";
            HttpResponseMessage responseMonitoringPosts = await _HttpApiClient.GetAsync(urlMonitoringPosts + routeMonitoringPosts);

            if (responseMonitoringPosts.IsSuccessStatusCode)
            {
                monitoringPosts = await responseMonitoringPosts.Content.ReadAsAsync <List <MonitoringPost> >();
            }
            ViewBag.MonitoringPosts = new SelectList(monitoringPosts.OrderBy(m => m.Name), "Id", "Name");

            return(View(ledScreens));
        }
Example #3
0
        // GET: MeasuredParameters
        public async Task <IActionResult> Index(string SortOrder,
                                                string NameKKFilter,
                                                string NameRUFilter,
                                                string NameENFilter,
                                                int?EcomonCodeFilter,
                                                string OceanusCodeFilter,
                                                string KazhydrometCodeFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <MeasuredParameter> measuredParameters = new List <MeasuredParameter>();

            ViewBag.NameKKFilter          = NameKKFilter;
            ViewBag.NameRUFilter          = NameRUFilter;
            ViewBag.NameENFilter          = NameENFilter;
            ViewBag.EcomonCodeFilter      = EcomonCodeFilter;
            ViewBag.OceanusCodeFilter     = OceanusCodeFilter;
            ViewBag.KazhydrometCodeFilter = KazhydrometCodeFilter;

            ViewBag.NameKKSort          = SortOrder == "NameKK" ? "NameKKDesc" : "NameKK";
            ViewBag.NameRUSort          = SortOrder == "NameRU" ? "NameRUDesc" : "NameRU";
            ViewBag.NameENSort          = SortOrder == "NameEN" ? "NameENDesc" : "NameEN";
            ViewBag.EcomonCodeSort      = SortOrder == "EcomonCode" ? "EcomonCodeDesc" : "EcomonCode";
            ViewBag.OceanusCodeSort     = SortOrder == "OceanusCode" ? "OceanusCodeDesc" : "OceanusCode";
            ViewBag.KazhydrometCodeSort = SortOrder == "KazhydrometCode" ? "KazhydrometCodeDesc" : "KazhydrometCode";

            string url        = "api/MeasuredParameters",
                   route      = "",
                   routeCount = "";

            if (!string.IsNullOrEmpty(SortOrder))
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"SortOrder={SortOrder}";
            }
            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 (!string.IsNullOrEmpty(NameENFilter))
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"NameEN={NameENFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"NameEN={NameENFilter}";
            }
            if (EcomonCodeFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"EcomonCode={EcomonCodeFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"EcomonCode={EcomonCodeFilter}";
            }
            if (OceanusCodeFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"OceanusCode={OceanusCodeFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"OceanusCode={OceanusCodeFilter}";
            }
            if (KazhydrometCodeFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"KazhydrometCode={KazhydrometCodeFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"KazhydrometCode={KazhydrometCodeFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                measuredParameters = await response.Content.ReadAsAsync <List <MeasuredParameter> >();
            }
            int measuredParametersCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                measuredParametersCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(measuredParametersCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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(measuredParameters));
        }
Example #4
0
        // GET: PollutionSourceDatas
        public async Task <IActionResult> Index(string SortOrder,
                                                int?PollutantIdFilter,
                                                int?PollutionSourceIdFilter,
                                                DateTime?DateTimeFromFilter,
                                                DateTime?DateTimeToFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <PollutionSourceData> pollutionSourceDatas = new List <PollutionSourceData>();

            ViewBag.PollutantIdFilter       = PollutantIdFilter;
            ViewBag.PollutionSourceIdFilter = PollutionSourceIdFilter;
            ViewBag.DateTimeFromFilter      = (DateTimeFromFilter)?.ToString("yyyy-MM-dd");
            ViewBag.DateTimeToFilter        = (DateTimeToFilter)?.ToString("yyyy-MM-dd");

            ViewBag.PollutantSort       = SortOrder == "Pollutant" ? "PollutantDesc" : "Pollutant";
            ViewBag.PollutionSourceSort = SortOrder == "PollutionSource" ? "PollutionSourceDesc" : "PollutionSource";
            ViewBag.DateTimeSort        = SortOrder == "DateTime" ? "DateTimeDesc" : "DateTime";

            string url        = "api/PollutionSourceDatas",
                   route      = "",
                   routeCount = "";

            if (!string.IsNullOrEmpty(SortOrder))
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"SortOrder={SortOrder}";
            }
            // Language
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"Language={new RequestLocalizationOptions().DefaultRequestCulture.Culture.Name}";
            }
            if (PollutantIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"PollutantId={PollutantIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"PollutantId={PollutantIdFilter}";
            }
            if (PollutionSourceIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"PollutionSourceId={PollutionSourceIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"PollutionSourceId={PollutionSourceIdFilter}";
            }
            if (DateTimeFromFilter != null)
            {
                DateTimeFormatInfo dateTimeFormatInfo = CultureInfo.CreateSpecificCulture("en").DateTimeFormat;
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"DateTimeFrom={DateTimeFromFilter?.ToString(dateTimeFormatInfo)}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"DateTimeFrom={DateTimeFromFilter?.ToString(dateTimeFormatInfo)}";
            }
            if (DateTimeToFilter != null)
            {
                DateTimeToFilter = DateTimeToFilter?.AddDays(1).AddMilliseconds(-1);
                DateTimeFormatInfo dateTimeFormatInfo = CultureInfo.CreateSpecificCulture("en").DateTimeFormat;
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"DateTimeTo={DateTimeToFilter?.ToString(dateTimeFormatInfo)}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"DateTimeTo={DateTimeToFilter?.ToString(dateTimeFormatInfo)}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                pollutionSourceDatas = await response.Content.ReadAsAsync <List <PollutionSourceData> >();
            }
            int pollutionSourceDatasCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                pollutionSourceDatasCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(pollutionSourceDatasCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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;
                }
            }

            List <Pollutant> pollutants            = new List <Pollutant>();
            string           urlPollutants         = "api/Pollutants",
                             routePollutants       = "";
            HttpResponseMessage responsePollutants = await _HttpApiClient.GetAsync(urlPollutants + routePollutants);

            if (responsePollutants.IsSuccessStatusCode)
            {
                pollutants = await responsePollutants.Content.ReadAsAsync <List <Pollutant> >();
            }
            ViewBag.Pollutants = new SelectList(pollutants.OrderBy(m => m.Name), "Id", "Name");

            List <PollutionSource> pollutionSources = new List <PollutionSource>();
            string urlPollutionSources   = "api/PollutionSources",
                   routePollutionSources = "";
            HttpResponseMessage responsePollutionSources = await _HttpApiClient.GetAsync(urlPollutionSources + routePollutionSources);

            if (responsePollutionSources.IsSuccessStatusCode)
            {
                pollutionSources = await responsePollutionSources.Content.ReadAsAsync <List <PollutionSource> >();
            }
            ViewBag.PollutionSources = new SelectList(pollutionSources.OrderBy(m => m.Name), "Id", "Name");

            return(View(pollutionSourceDatas));
        }
Example #5
0
        public async Task <IActionResult> EcoserviceMonitoringPosts()
        {
            string role = HttpContext.Session.GetString("Role");

            if (!(role == "admin" || role == "moderator" || role == "KaragandaRegion"))
            {
                return(Redirect("/"));
            }

            string urlMonitoringPosts                     = "api/MonitoringPosts";
            List <MonitoringPost> monitoringPosts         = new List <MonitoringPost>();
            HttpResponseMessage   responseMonitoringPosts = await _HttpApiClient.GetAsync(urlMonitoringPosts);

            monitoringPosts = await responseMonitoringPosts.Content.ReadAsAsync <List <MonitoringPost> >();

            List <MonitoringPost> ecoserviceAirMonitoringPosts = monitoringPosts
                                                                 .Where(m => m.DataProvider.Name == Startup.Configuration["EcoserviceName"].ToString())
                                                                 .OrderBy(m => m.Name)
                                                                 .ToList();

            ViewBag.EcoserviceAirMonitoringPosts = ecoserviceAirMonitoringPosts.ToArray();

            string urlMeasuredParameters = "api/MeasuredParameters";
            List <MeasuredParameter> measuredParameters         = new List <MeasuredParameter>();
            HttpResponseMessage      responseMeasuredParameters = await _HttpApiClient.GetAsync(urlMeasuredParameters);

            measuredParameters = await responseMeasuredParameters.Content.ReadAsAsync <List <MeasuredParameter> >();

            measuredParameters = measuredParameters
                                 .Where(m => !string.IsNullOrEmpty(m.OceanusCode))
                                 .OrderBy(m => m.Name)
                                 .ToList();
            ViewBag.MeasuredParameters = measuredParameters.ToArray();

            int MPCExceedPastMinutes = Convert.ToInt32(Startup.Configuration["MPCExceedPastMinutes"]),
                InactivePastMinutes  = Convert.ToInt32(Startup.Configuration["InactivePastMinutes"]);

            ViewBag.PastMinutes = Math.Max(MPCExceedPastMinutes, InactivePastMinutes);

            return(View());
        }
Example #6
0
        // GET: SpeciesDiversities
        public async Task <IActionResult> Index(string SortOrder,
                                                int?KATOIdFilter,
                                                int?PlantationsTypeIdFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <SpeciesDiversity> speciesDiversities = new List <SpeciesDiversity>();

            ViewBag.KATOIdFilter            = KATOIdFilter;
            ViewBag.PlantationsTypeIdFilter = PlantationsTypeIdFilter;

            ViewBag.KATOSort            = SortOrder == "KATO" ? "KATODesc" : "KATO";
            ViewBag.PlantationsTypeSort = SortOrder == "PlantationsType" ? "PlantationsTypeDesc" : "PlantationsType";

            string url        = "api/SpeciesDiversities",
                   route      = "",
                   routeCount = "";

            if (!string.IsNullOrEmpty(SortOrder))
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"SortOrder={SortOrder}";
            }
            if (KATOIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"KATOId={KATOIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"KATOId={KATOIdFilter}";
            }
            if (PlantationsTypeIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"PlantationsTypeId={PlantationsTypeIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"PlantationsTypeId={PlantationsTypeIdFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                speciesDiversities = await response.Content.ReadAsAsync <List <SpeciesDiversity> >();
            }
            int plantationsStateCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                plantationsStateCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(plantationsStateCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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;
                }
            }

            List <KATO> KATOes      = new List <KATO>();
            string      urlKATOes   = "api/KATOes",
                        routeKATOes = "";
            HttpResponseMessage responseKATOes = await _HttpApiClient.GetAsync(urlKATOes + routeKATOes);

            if (responseKATOes.IsSuccessStatusCode)
            {
                KATOes = await responseKATOes.Content.ReadAsAsync <List <KATO> >();
            }
            ViewBag.KATOes = new SelectList(KATOes.Where(k => k.ParentEgovId == 17112).OrderBy(m => m.Name), "Id", "Name");

            List <PlantationsType> plantationsTypes = new List <PlantationsType>();
            string urlPlantationsTypes   = "api/PlantationsTypes",
                   routePlantationsTypes = "";
            HttpResponseMessage responsePlantationsTypes = await _HttpApiClient.GetAsync(urlPlantationsTypes + routePlantationsTypes);

            if (responsePlantationsTypes.IsSuccessStatusCode)
            {
                plantationsTypes = await responsePlantationsTypes.Content.ReadAsAsync <List <PlantationsType> >();
            }
            ViewBag.PlantationsTypes = new SelectList(plantationsTypes.OrderBy(m => m.Name), "Id", "Name");

            return(View(speciesDiversities));
        }
        // GET: TreesByObjectTableOfTheBreedStateLists
        public async Task <IActionResult> Index(string SortOrder,
                                                int?GreemPlantsPassportIdFilter,
                                                int?PlantationsTypeIdFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <TreesByObjectTableOfTheBreedStateList> treesByObjectTableOfTheBreedStateLists = new List <TreesByObjectTableOfTheBreedStateList>();

            ViewBag.GreemPlantsPassportIdFilter = GreemPlantsPassportIdFilter;
            ViewBag.PlantationsTypeIdFilter     = PlantationsTypeIdFilter;

            ViewBag.GreemPlantsPassportSort = SortOrder == "GreemPlantsPassport" ? "GreemPlantsPassportDesc" : "GreemPlantsPassport";
            ViewBag.PlantationsTypeSort     = SortOrder == "PlantationsType" ? "PlantationsTypeDesc" : "PlantationsType";
            ViewBag.QuantitySort            = SortOrder == "Quantity" ? "QuantityDesc" : "Quantity";

            string url        = "api/TreesByObjectTableOfTheBreedStateLists",
                   route      = "",
                   routeCount = "";

            if (GreemPlantsPassportIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"GreemPlantsPassportId={GreemPlantsPassportIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"GreemPlantsPassportId={GreemPlantsPassportIdFilter}";
            }
            if (PlantationsTypeIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"PlantationsTypeId={PlantationsTypeIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"PlantationsTypeId={PlantationsTypeIdFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                treesByObjectTableOfTheBreedStateLists = await response.Content.ReadAsAsync <List <TreesByObjectTableOfTheBreedStateList> >();
            }
            int treesByObjectTableOfTheBreedStateListCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                treesByObjectTableOfTheBreedStateListCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(treesByObjectTableOfTheBreedStateListCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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;
                }
            }

            List <PlantationsType> plantationsTypes = new List <PlantationsType>();
            string urlPlantationsTypes   = "api/PlantationsTypes",
                   routePlantationsTypes = "";
            HttpResponseMessage responsePlantationsTypes = await _HttpApiClient.GetAsync(urlPlantationsTypes + routePlantationsTypes);

            if (responsePlantationsTypes.IsSuccessStatusCode)
            {
                plantationsTypes = await responsePlantationsTypes.Content.ReadAsAsync <List <PlantationsType> >();
            }
            ViewBag.PlantationsTypes = new SelectList(plantationsTypes.OrderBy(m => m.Name), "Id", "Name");

            List <GreemPlantsPassport> greemPlantsPassports = new List <GreemPlantsPassport>();
            string urlGreemPlantsPassports   = "api/GreemPlantsPassports",
                   routeGreemPlantsPassports = "";
            HttpResponseMessage responseGreemPlantsPassports = await _HttpApiClient.GetAsync(urlGreemPlantsPassports + routeGreemPlantsPassports);

            if (responseGreemPlantsPassports.IsSuccessStatusCode)
            {
                greemPlantsPassports = await responseGreemPlantsPassports.Content.ReadAsAsync <List <GreemPlantsPassport> >();
            }
            ViewBag.GreemPlantsPassports = new SelectList(greemPlantsPassports.OrderBy(m => m.GreenObject), "Id", "GreenObject");

            return(View(treesByObjectTableOfTheBreedStateLists));
        }
Example #8
0
        // GET: KazHydrometSoilPosts
        public async Task <IActionResult> Index(string SortOrder,
                                                int?NumberFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <KazHydrometSoilPost> kazHydrometSoilPosts = new List <KazHydrometSoilPost>();

            ViewBag.NumberFilter = NumberFilter;

            ViewBag.NumberSort = SortOrder == "Number" ? "NumberDesc" : "Number";

            string url        = "api/KazHydrometSoilPosts",
                   route      = "",
                   routeCount = "";

            if (!string.IsNullOrEmpty(SortOrder))
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"SortOrder={SortOrder}";
            }
            if (NumberFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"Number={NumberFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"Number={NumberFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                kazHydrometSoilPosts = await response.Content.ReadAsAsync <List <KazHydrometSoilPost> >();
            }
            int kazHydrometSoilPostCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                kazHydrometSoilPostCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(kazHydrometSoilPostCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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(kazHydrometSoilPosts));
        }
Example #9
0
        // GET: Targets
        public async Task <IActionResult> Index(string SortOrder,
                                                string NameKKFilter,
                                                string NameRUFilter,
                                                string NameENFilter,
                                                int?PollutionEnvironmentIdFilter,
                                                int?ProjectIdFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <Target> targets = new List <Target>();

            ViewBag.NameKKFilter = NameKKFilter;
            ViewBag.NameRUFilter = NameRUFilter;
            ViewBag.NameENFilter = NameENFilter;
            ViewBag.PollutionEnvironmentIdFilter = PollutionEnvironmentIdFilter;
            ViewBag.ProjectIdFilter = ProjectIdFilter;

            ViewBag.NameKKSort = SortOrder == "NameKK" ? "NameKKDesc" : "NameKK";
            ViewBag.NameRUSort = SortOrder == "NameRU" ? "NameRUDesc" : "NameRU";
            ViewBag.NameENSort = SortOrder == "NameEN" ? "NameENDesc" : "NameEN";
            ViewBag.PollutionEnvironmentSort = SortOrder == "PollutionEnvironment" ? "PollutionEnvironmentDesc" : "PollutionEnvironment";
            ViewBag.ProjectSort = SortOrder == "Project" ? "ProjectDesc" : "Project";

            string url        = "api/Targets",
                   route      = "",
                   routeCount = "";

            if (!string.IsNullOrEmpty(SortOrder))
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"SortOrder={SortOrder}";
            }
            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 (!string.IsNullOrEmpty(NameENFilter))
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"NameEN={NameENFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"NameEN={NameENFilter}";
            }
            if (PollutionEnvironmentIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"PollutionEnvironmentId={PollutionEnvironmentIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"PollutionEnvironmentId={PollutionEnvironmentIdFilter}";
            }
            if (ProjectIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"ProjectId={ProjectIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"ProjectId={ProjectIdFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                targets = await response.Content.ReadAsAsync <List <Target> >();
            }
            int targetsCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                targetsCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(targetsCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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;
                }
            }

            List <PollutionEnvironment> pollutionEnvironments = new List <PollutionEnvironment>();
            string urlPollutionEnvironments   = "api/PollutionEnvironments",
                   routePollutionEnvironments = "";
            HttpResponseMessage responsePollutionEnvironments = await _HttpApiClient.GetAsync(urlPollutionEnvironments + routePollutionEnvironments);

            if (responsePollutionEnvironments.IsSuccessStatusCode)
            {
                pollutionEnvironments = await responsePollutionEnvironments.Content.ReadAsAsync <List <PollutionEnvironment> >();
            }
            ViewBag.PollutionEnvironments = new SelectList(pollutionEnvironments.OrderBy(m => m.Name), "Id", "Name");

            List <Project> projects              = new List <Project>();
            string         urlProjects           = "api/Projects",
                           routeProjects         = "";
            HttpResponseMessage responseProjects = await _HttpApiClient.GetAsync(urlProjects + routeProjects);

            if (responseProjects.IsSuccessStatusCode)
            {
                projects = await responseProjects.Content.ReadAsAsync <List <Project> >();
            }
            ViewBag.Projects = new SelectList(projects.OrderBy(m => m.Name), "Id", "Name");

            return(View(targets));
        }
Example #10
0
        // GET: MeasuredDatas
        public async Task <IActionResult> Index(string SortOrder,
                                                int?MeasuredParameterIdFilter,
                                                DateTime?DateTimeFromFilter,
                                                DateTime?DateTimeToFilter,
                                                int?MonitoringPostIdFilter,
                                                int?PollutionSourceIdFilter,
                                                bool?AveragedFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <MeasuredData> measuredDatas = new List <MeasuredData>();

            ViewBag.MeasuredParameterIdFilter = MeasuredParameterIdFilter;
            ViewBag.DateTimeFromFilter        = (DateTimeFromFilter)?.ToString("yyyy-MM-dd");
            ViewBag.DateTimeToFilter          = (DateTimeToFilter)?.ToString("yyyy-MM-dd");
            ViewBag.MonitoringPostIdFilter    = MonitoringPostIdFilter;
            ViewBag.PollutionSourceIdFilter   = PollutionSourceIdFilter;
            ViewBag.AveragedFilter            = AveragedFilter;

            ViewBag.MeasuredParameterSort = SortOrder == "MeasuredParameter" ? "MeasuredParameterDesc" : "MeasuredParameter";
            ViewBag.DateTimeSort          = SortOrder == "DateTime" ? "DateTimeDesc" : "DateTime";
            ViewBag.MonitoringPostSort    = SortOrder == "MonitoringPost" ? "MonitoringPostDesc" : "MonitoringPost";
            ViewBag.PollutionSourceSort   = SortOrder == "PollutionSource" ? "PollutionSourceDesc" : "PollutionSource";

            string url        = "api/MeasuredDatas",
                   route      = "",
                   routeCount = "";

            if (!string.IsNullOrEmpty(SortOrder))
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"SortOrder={SortOrder}";
            }
            // Language
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"Language={new RequestLocalizationOptions().DefaultRequestCulture.Culture.Name}";
            }
            if (MeasuredParameterIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"MeasuredParameterId={MeasuredParameterIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"MeasuredParameterId={MeasuredParameterIdFilter}";
            }
            if (DateTimeFromFilter != null)
            {
                DateTimeFormatInfo dateTimeFormatInfo = CultureInfo.CreateSpecificCulture("en").DateTimeFormat;
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"DateTimeFrom={DateTimeFromFilter?.ToString(dateTimeFormatInfo)}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"DateTimeFrom={DateTimeFromFilter?.ToString(dateTimeFormatInfo)}";
            }
            if (DateTimeToFilter != null)
            {
                DateTimeToFilter = DateTimeToFilter?.AddDays(1).AddMilliseconds(-1);
                DateTimeFormatInfo dateTimeFormatInfo = CultureInfo.CreateSpecificCulture("en").DateTimeFormat;
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"DateTimeTo={DateTimeToFilter?.ToString(dateTimeFormatInfo)}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"DateTimeTo={DateTimeToFilter?.ToString(dateTimeFormatInfo)}";
            }
            if (MonitoringPostIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"MonitoringPostId={MonitoringPostIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"MonitoringPostId={MonitoringPostIdFilter}";
            }
            if (PollutionSourceIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"PollutionSourceId={PollutionSourceIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"PollutionSourceId={PollutionSourceIdFilter}";
            }
            if (AveragedFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"Averaged={AveragedFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"Averaged={AveragedFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                measuredDatas = await response.Content.ReadAsAsync <List <MeasuredData> >();

                string csv = "";
                foreach (MeasuredData measuredData in measuredDatas)
                {
                    csv += measuredData.MonitoringPost.NorthLatitude + ";" +
                           measuredData.MonitoringPost.EastLongitude + ";" +
                           measuredData.Value + ";" +
                           measuredData.DateTime.ToString() +
                           Environment.NewLine;
                }
            }
            int measuredDatasCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                measuredDatasCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(measuredDatasCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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;
                }
            }

            List <MeasuredParameter> measuredParameters = new List <MeasuredParameter>();
            string urlMeasuredParameters   = "api/MeasuredParameters",
                   routeMeasuredParameters = "";
            HttpResponseMessage responseMeasuredParameters = await _HttpApiClient.GetAsync(urlMeasuredParameters + routeMeasuredParameters);

            if (responseMeasuredParameters.IsSuccessStatusCode)
            {
                measuredParameters = await responseMeasuredParameters.Content.ReadAsAsync <List <MeasuredParameter> >();
            }
            ViewBag.MeasuredParameters = new SelectList(measuredParameters.OrderBy(m => m.Name), "Id", "Name");

            List <EcomonMonitoringPoint> ecomonMonitoringPoints = new List <EcomonMonitoringPoint>();
            string urlEcomonMonitoringPoints   = "api/EcomonMonitoringPoints",
                   routeEcomonMonitoringPoints = "";
            HttpResponseMessage responseEcomonMonitoringPoints = await _HttpApiClient.GetAsync(urlEcomonMonitoringPoints + routeEcomonMonitoringPoints);

            if (responseEcomonMonitoringPoints.IsSuccessStatusCode)
            {
                ecomonMonitoringPoints = await responseEcomonMonitoringPoints.Content.ReadAsAsync <List <EcomonMonitoringPoint> >();
            }
            ViewBag.EcomonMonitoringPoints = new SelectList(ecomonMonitoringPoints.OrderBy(m => m.Number), "Id", "Number");

            List <KazHydrometAirPost> kazHydrometAirPosts = new List <KazHydrometAirPost>();
            string urlKazHydrometAirPosts   = "api/KazHydrometAirPosts",
                   routeKazHydrometAirPosts = "";
            HttpResponseMessage responseKazHydrometAirPosts = await _HttpApiClient.GetAsync(urlKazHydrometAirPosts + routeKazHydrometAirPosts);

            if (responseKazHydrometAirPosts.IsSuccessStatusCode)
            {
                kazHydrometAirPosts = await responseKazHydrometAirPosts.Content.ReadAsAsync <List <KazHydrometAirPost> >();
            }
            ViewBag.KazHydrometAirPosts = new SelectList(kazHydrometAirPosts.OrderBy(m => m.Name), "Id", "Name");

            List <MonitoringPost> monitoringPosts       = new List <MonitoringPost>();
            string urlMonitoringPosts                   = "api/MonitoringPosts",
                   routeMonitoringPosts                 = "";
            HttpResponseMessage responseMonitoringPosts = await _HttpApiClient.GetAsync(urlMonitoringPosts + routeMonitoringPosts);

            if (responseMonitoringPosts.IsSuccessStatusCode)
            {
                monitoringPosts = await responseMonitoringPosts.Content.ReadAsAsync <List <MonitoringPost> >();
            }
            ViewBag.MonitoringPosts = new SelectList(monitoringPosts.OrderBy(m => m.Name), "Id", "Name");

            List <PollutionSource> pollutionSources = new List <PollutionSource>();
            string urlPollutionSources   = "api/PollutionSources",
                   routePollutionSources = "";
            HttpResponseMessage responsePollutionSources = await _HttpApiClient.GetAsync(urlPollutionSources + routePollutionSources);

            if (responsePollutionSources.IsSuccessStatusCode)
            {
                pollutionSources = await responsePollutionSources.Content.ReadAsAsync <List <PollutionSource> >();
            }
            ViewBag.PollutionSources = new SelectList(pollutionSources.OrderBy(m => m.Name), "Id", "Name");

            return(View(measuredDatas));
        }
        // GET: SpeciallyProtectedNaturalTerritories
        public async Task <IActionResult> Index(string SortOrder,
                                                string NameENFilter,
                                                string NameRUFilter,
                                                string NameKKFilter,
                                                int?AuthorizedAuthorityIdFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <SpeciallyProtectedNaturalTerritory> speciallyProtectedNaturalTerritories = new List <SpeciallyProtectedNaturalTerritory>();

            ViewBag.NameENFilter = NameENFilter;
            ViewBag.NameRUFilter = NameRUFilter;
            ViewBag.NameKKFilter = NameKKFilter;
            ViewBag.AuthorizedAuthorityIdFilter = AuthorizedAuthorityIdFilter;

            ViewBag.NameENSort = SortOrder == "NameEN" ? "NameENDesc" : "NameEN";
            ViewBag.NameRUSort = SortOrder == "NameRU" ? "NameRUDesc" : "NameRU";
            ViewBag.NameKKSort = SortOrder == "NameKK" ? "NameKKDesc" : "NameKK";
            ViewBag.AuthorizedAuthoritySort = SortOrder == "AuthorizedAuthority" ? "AuthorizedAuthorityDesc" : "AuthorizedAuthority";

            string url        = "api/SpeciallyProtectedNaturalTerritories",
                   route      = "",
                   routeCount = "";

            if (!string.IsNullOrEmpty(SortOrder))
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"SortOrder={SortOrder}";
            }
            if (NameENFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"NameEN={NameENFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"NameEN={NameENFilter}";
            }
            if (NameRUFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"NameRU={NameRUFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"NameRU={NameRUFilter}";
            }
            if (NameKKFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"NameKK={NameKKFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"NameKK={NameKKFilter}";
            }
            if (AuthorizedAuthorityIdFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"AuthorizedAuthorityId={AuthorizedAuthorityIdFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"AuthorizedAuthorityId={AuthorizedAuthorityIdFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                speciallyProtectedNaturalTerritories = await response.Content.ReadAsAsync <List <SpeciallyProtectedNaturalTerritory> >();
            }
            int speciallyProtectedNaturalTerritoryCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                speciallyProtectedNaturalTerritoryCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(speciallyProtectedNaturalTerritoryCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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;
                }
            }

            List <AuthorizedAuthority> authorizedAuthorities = new List <AuthorizedAuthority>();
            string urlAuthorizedAuthorities   = "api/AuthorizedAuthorities",
                   routeAuthorizedAuthorities = "";
            HttpResponseMessage responseAuthorizedAuthorities = await _HttpApiClient.GetAsync(urlAuthorizedAuthorities + routeAuthorizedAuthorities);

            if (responseAuthorizedAuthorities.IsSuccessStatusCode)
            {
                authorizedAuthorities = await responseAuthorizedAuthorities.Content.ReadAsAsync <List <AuthorizedAuthority> >();
            }
            ViewBag.AuthorizedAuthorities = new SelectList(authorizedAuthorities.OrderBy(m => m.Name), "Id", "Name");

            return(View(speciallyProtectedNaturalTerritories));
        }
        // GET: ReceptionRecyclingPoints
        public async Task <IActionResult> Index(string SortOrder,
                                                string OrganizationFilter,
                                                string TypesRawFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            List <ReceptionRecyclingPoint> receptionRecyclingPoints = new List <ReceptionRecyclingPoint>();

            ViewBag.OrganizationFilter = OrganizationFilter;
            ViewBag.TypesRawFilter     = TypesRawFilter;

            ViewBag.OrganizationSort = SortOrder == "Organization" ? "OrganizationDesc" : "Organization";
            ViewBag.TypesRawSort     = SortOrder == "TypesRaw" ? "TypesRawDesc" : "TypesRaw";

            string url        = "api/ReceptionRecyclingPoints",
                   route      = "",
                   routeCount = "";

            if (OrganizationFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"Organization={OrganizationFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"Organization={OrganizationFilter}";
            }
            if (TypesRawFilter != null)
            {
                route      += string.IsNullOrEmpty(route) ? "?" : "&";
                route      += $"TypesRaw={TypesRawFilter}";
                routeCount += string.IsNullOrEmpty(routeCount) ? "?" : "&";
                routeCount += $"TypesRaw={TypesRawFilter}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }
            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                receptionRecyclingPoints = await response.Content.ReadAsAsync <List <ReceptionRecyclingPoint> >();
            }
            int receptionRecyclingPointCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                receptionRecyclingPointCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(receptionRecyclingPointCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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;
                }
            }

            List <Project> projects              = new List <Project>();
            string         urlProjects           = "api/Projects",
                           routeProjects         = "";
            HttpResponseMessage responseProjects = await _HttpApiClient.GetAsync(urlProjects + routeProjects);

            if (responseProjects.IsSuccessStatusCode)
            {
                projects = await responseProjects.Content.ReadAsAsync <List <Project> >();
            }
            ViewBag.Projects = new SelectList(projects.OrderBy(m => m.Name), "Id", "Name");

            return(View(receptionRecyclingPoints));
        }
Example #13
0
        // GET: Projects
        public async Task <IActionResult> Index(string SortOrder,
                                                string NameFilter,
                                                int?PageSize,
                                                int?PageNumber)
        {
            //string token = HttpContext.Session.GetString("Token");

            List <Project> projects = new List <Project>();

            ViewBag.NameFilter = NameFilter;

            ViewBag.NameSort = SortOrder == "Name" ? "NameDesc" : "Name";

            string url        = "api/Projects",
                   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}";
            }
            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }

            //_HttpApiClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                projects = await response.Content.ReadAsAsync <List <Project> >();
            }
            int projectsCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                projectsCount = await responseCount.Content.ReadAsAsync <int>();
            }
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages = PageSize != null ? (int)Math.Ceiling(projectsCount / (decimal)PageSize) : 1;
            ViewBag.StartPage  = PageNumber - 5;
            ViewBag.EndPage    = PageNumber + 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(projects));
        }
Example #14
0
        // GET: AppealCitizens
        public async Task <IActionResult> Index(
            int?PageSize,
            int?PageNumber)
        {
            PersonQuestions personQuestions = new PersonQuestions();

            string url        = "api/AppealCitizens",
                   route      = "",
                   routeCount = "";

            IConfigurationSection pageSizeListSection = Startup.Configuration.GetSection("PageSizeList");
            var pageSizeList = pageSizeListSection.AsEnumerable().Where(p => p.Value != null);

            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 (PageNumber == null)
                {
                    PageNumber = 1;
                }
            }
            if (PageNumber != null)
            {
                route += string.IsNullOrEmpty(route) ? "?" : "&";
                route += $"PageNumber={PageNumber.ToString()}";
            }

            HttpResponseMessage response      = await _HttpApiClient.GetAsync(url + "/GetQuestionsAndAnswers" + route),
                                responseCount = await _HttpApiClient.GetAsync(url + "/Count" + routeCount);

            if (response.IsSuccessStatusCode)
            {
                personQuestions = await response.Content.ReadAsAsync <PersonQuestions>();
            }
            int questionsCount = 0;

            if (responseCount.IsSuccessStatusCode)
            {
                questionsCount = await responseCount.Content.ReadAsAsync <int>();
            }

            ViewBag.PersonQuestions = personQuestions;
            ViewBag.PageSize        = PageSize;
            ViewBag.PageNumber      = PageNumber != null ? PageNumber : 1;
            ViewBag.TotalPages      = PageSize != null ? (int)Math.Ceiling(questionsCount / (decimal)PageSize) : 1;
            ViewBag.StartPage       = PageNumber - 5;
            ViewBag.EndPage         = PageNumber + 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());
        }