public async Task <ActionResult <TargetTerritory> > PostTargetTerritory(TargetTerritory targetTerritory)
        {
            _context.TargetTerritory.Add(targetTerritory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTargetTerritory", new { id = targetTerritory.Id }, targetTerritory));
        }
        public async Task <IActionResult> PutTargetTerritory(int id, TargetTerritory targetTerritory)
        {
            if (id != targetTerritory.Id)
            {
                return(BadRequest());
            }

            _context.Entry(targetTerritory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TargetTerritoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        // GET: TargetTerritories/Delete/5
        public async Task <IActionResult> Delete(int?id,
                                                 string SortOrder,
                                                 string NameKKFilter,
                                                 string NameRUFilter,
                                                 string GISConnectionCodeFilter,
                                                 int?TerritoryTypeIdFilter,
                                                 int?ProjectIdFilter,
                                                 int?PageSize,
                                                 int?PageNumber)
        {
            ViewBag.SortOrder               = SortOrder;
            ViewBag.PageSize                = PageSize;
            ViewBag.PageNumber              = PageNumber;
            ViewBag.NameKKFilter            = NameKKFilter;
            ViewBag.NameRUFilter            = NameRUFilter;
            ViewBag.GISConnectionCodeFilter = GISConnectionCodeFilter;
            ViewBag.TerritoryTypeIdFilter   = TerritoryTypeIdFilter;
            ViewBag.ProjectIdFilter         = ProjectIdFilter;
            if (id == null)
            {
                return(NotFound());
            }

            TargetTerritory     targetTerritory = null;
            HttpResponseMessage response        = await _HttpApiClient.GetAsync($"api/TargetTerritories/{id.ToString()}");

            if (response.IsSuccessStatusCode)
            {
                targetTerritory = await response.Content.ReadAsAsync <TargetTerritory>();
            }
            if (targetTerritory == null)
            {
                return(NotFound());
            }

            List <TargetValue> targetValues          = new List <TargetValue>();
            string             urlTargetValues       = "api/TargetValues",
                               routeTargetValues     = "";
            HttpResponseMessage responseTargetValues = await _HttpApiClient.GetAsync(urlTargetValues + routeTargetValues);

            if (responseTargetValues.IsSuccessStatusCode)
            {
                targetValues = await responseTargetValues.Content.ReadAsAsync <List <TargetValue> >();
            }
            ViewBag.TargetValues = targetValues.Where(t => t.TargetTerritoryId == id).AsQueryable();

            List <AActivity> aActivities            = new List <AActivity>();
            string           urlAActivities         = "api/AActivities",
                             routeAActivities       = "";
            HttpResponseMessage responseAActivities = await _HttpApiClient.GetAsync(urlAActivities + routeAActivities);

            if (responseAActivities.IsSuccessStatusCode)
            {
                aActivities = await responseAActivities.Content.ReadAsAsync <List <AActivity> >();
            }
            ViewBag.AActivities = aActivities.Where(t => t.TargetTerritoryId == id).AsQueryable();

            return(View(targetTerritory));
        }
Exemplo n.º 4
0
        // GET: TargetTerritories/Details/5
        public async Task <IActionResult> Details(int?id,
                                                  string SortOrder,
                                                  string NameKKFilter,
                                                  string NameRUFilter,
                                                  string GISConnectionCodeFilter,
                                                  int?TerritoryTypeIdFilter,
                                                  int?ProjectIdFilter,
                                                  int?PageSize,
                                                  int?PageNumber)
        {
            ViewBag.SortOrder               = SortOrder;
            ViewBag.PageSize                = PageSize;
            ViewBag.PageNumber              = PageNumber;
            ViewBag.NameKKFilter            = NameKKFilter;
            ViewBag.NameRUFilter            = NameRUFilter;
            ViewBag.GISConnectionCodeFilter = GISConnectionCodeFilter;
            ViewBag.TerritoryTypeIdFilter   = TerritoryTypeIdFilter;
            ViewBag.ProjectIdFilter         = ProjectIdFilter;
            if (id == null)
            {
                return(NotFound());
            }

            TargetTerritory     targetTerritory = null;
            HttpResponseMessage response        = await _HttpApiClient.GetAsync($"api/TargetTerritories/{id.ToString()}");

            if (response.IsSuccessStatusCode)
            {
                targetTerritory = await response.Content.ReadAsAsync <TargetTerritory>();
            }
            if (targetTerritory == null)
            {
                return(NotFound());
            }

            return(View(targetTerritory));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TerritoryTypeId,KATOId,NameKK,NameRU,GISConnectionCode,AdditionalInformationKK,AdditionalInformationRU,MonitoringPostId,KazHydrometSoilPostId,ProjectId")] TargetTerritory targetTerritory,
                                               string SortOrder,
                                               string NameKKFilter,
                                               string NameRUFilter,
                                               string GISConnectionCodeFilter,
                                               int?TerritoryTypeIdFilter,
                                               int?ProjectIdFilter,
                                               int?PageSize,
                                               int?PageNumber)
        {
            ViewBag.SortOrder               = SortOrder;
            ViewBag.PageSize                = PageSize;
            ViewBag.PageNumber              = PageNumber;
            ViewBag.NameKKFilter            = NameKKFilter;
            ViewBag.NameRUFilter            = NameRUFilter;
            ViewBag.GISConnectionCodeFilter = GISConnectionCodeFilter;
            ViewBag.TerritoryTypeIdFilter   = TerritoryTypeIdFilter;
            ViewBag.ProjectIdFilter         = ProjectIdFilter;
            if (id != targetTerritory.Id)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                HttpResponseMessage response = await _HttpApiClient.PutAsJsonAsync(
                    $"api/TargetTerritories/{targetTerritory.Id}", targetTerritory);

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

                OutputViewText = OutputViewText.Replace("<br>", Environment.NewLine);
                try
                {
                    response.EnsureSuccessStatusCode();
                }
                catch
                {
                    dynamic errors = JsonConvert.DeserializeObject <dynamic>(OutputViewText);
                    foreach (Newtonsoft.Json.Linq.JProperty property in errors.Children())
                    {
                        ModelState.AddModelError(property.Name, property.Value[0].ToString());
                    }
                    return(View(targetTerritory));
                }

                targetTerritory = await response.Content.ReadAsAsync <TargetTerritory>();

                return(RedirectToAction(nameof(Index),
                                        new
                {
                    SortOrder = ViewBag.SortOrder,
                    PageSize = ViewBag.PageSize,
                    PageNumber = ViewBag.PageNumber,
                    NameKKFilter = ViewBag.NameKKFilter,
                    NameRUFilter = ViewBag.NameRUFilter,
                    GISConnectionCodeFilter = ViewBag.GISConnectionCodeFilter,
                    TerritoryTypeIdFilter = ViewBag.TerritoryTypeIdFilter,
                    ProjectIdFilter = ViewBag.ProjectIdFilter
                }));
            }

            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.TransportPosts        = new SelectList(monitoringPosts.Where(m => m.PollutionEnvironmentId == 7).OrderBy(m => m.Name), "Id", "Name");
            ViewBag.KazHydrometWaterPosts = new SelectList(monitoringPosts.Where(m => m.PollutionEnvironmentId == 3 && m.DataProviderId == 1).OrderBy(m => m.Name), "Id", "Name");
            ViewBag.KazHydrometAirPosts   = new SelectList(monitoringPosts.Where(m => m.PollutionEnvironmentId == 2 && m.DataProviderId == 1).OrderBy(m => m.Name), "Id", "Name");

            List <KazHydrometSoilPost> kazHydrometSoilPosts = new List <KazHydrometSoilPost>();
            string urlKazHydrometSoilPosts   = "api/KazHydrometSoilPosts",
                   routeKazHydrometSoilPosts = "";
            HttpResponseMessage responseKazHydrometSoilPosts = await _HttpApiClient.GetAsync(urlKazHydrometSoilPosts + routeKazHydrometSoilPosts);

            if (responseKazHydrometSoilPosts.IsSuccessStatusCode)
            {
                kazHydrometSoilPosts = await responseKazHydrometSoilPosts.Content.ReadAsAsync <List <KazHydrometSoilPost> >();
            }
            ViewBag.KazHydrometSoilPosts = new SelectList(kazHydrometSoilPosts.OrderBy(m => m.Name), "Id", "Name", targetTerritory.KazHydrometSoilPostId);

            List <TerritoryType> territoryTypes        = new List <TerritoryType>();
            string urlTerritoryTypes                   = "api/TerritoryTypes",
                   routeTerritoryTypes                 = "";
            HttpResponseMessage responseTerritoryTypes = await _HttpApiClient.GetAsync(urlTerritoryTypes + routeTerritoryTypes);

            if (responseTerritoryTypes.IsSuccessStatusCode)
            {
                territoryTypes = await responseTerritoryTypes.Content.ReadAsAsync <List <TerritoryType> >();
            }
            ViewBag.TerritoryTypes = new SelectList(territoryTypes.OrderBy(m => m.Name), "Id", "Name", targetTerritory.TerritoryTypeId);

            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", targetTerritory.KATOId);

            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", targetTerritory.ProjectId);

            return(View(targetTerritory));
        }
Exemplo n.º 6
0
        // GET: TargetTerritories/Edit/5
        public async Task <IActionResult> Edit(int?id,
                                               string SortOrder,
                                               string NameKKFilter,
                                               string NameRUFilter,
                                               string GISConnectionCodeFilter,
                                               int?TerritoryTypeIdFilter,
                                               int?ProjectIdFilter,
                                               int?PageSize,
                                               int?PageNumber)
        {
            ViewBag.SortOrder               = SortOrder;
            ViewBag.PageSize                = PageSize;
            ViewBag.PageNumber              = PageNumber;
            ViewBag.NameKKFilter            = NameKKFilter;
            ViewBag.NameRUFilter            = NameRUFilter;
            ViewBag.GISConnectionCodeFilter = GISConnectionCodeFilter;
            ViewBag.TerritoryTypeIdFilter   = TerritoryTypeIdFilter;
            ViewBag.ProjectIdFilter         = ProjectIdFilter;
            TargetTerritory     targetTerritory = null;
            HttpResponseMessage response        = await _HttpApiClient.GetAsync($"api/TargetTerritories/{id.ToString()}");

            if (response.IsSuccessStatusCode)
            {
                targetTerritory = await response.Content.ReadAsAsync <TargetTerritory>();
            }

            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.TransportPosts        = new SelectList(monitoringPosts.Where(m => m.PollutionEnvironmentId == 7).OrderBy(m => m.Name), "Id", "Name", targetTerritory.MonitoringPostId);
            ViewBag.KazHydrometWaterPosts = new SelectList(monitoringPosts.Where(m => m.PollutionEnvironmentId == 3 && m.DataProviderId == 1).OrderBy(m => m.Name), "Id", "Name", targetTerritory.MonitoringPostId);
            ViewBag.KazHydrometAirPosts   = new SelectList(monitoringPosts.Where(m => m.PollutionEnvironmentId == 2 && m.DataProviderId == 1).OrderBy(m => m.Name), "Id", "Name", targetTerritory.MonitoringPostId);

            List <KazHydrometSoilPost> kazHydrometSoilPosts = new List <KazHydrometSoilPost>();
            string urlKazHydrometSoilPosts   = "api/KazHydrometSoilPosts",
                   routeKazHydrometSoilPosts = "";
            HttpResponseMessage responseKazHydrometSoilPosts = await _HttpApiClient.GetAsync(urlKazHydrometSoilPosts + routeKazHydrometSoilPosts);

            if (responseKazHydrometSoilPosts.IsSuccessStatusCode)
            {
                kazHydrometSoilPosts = await responseKazHydrometSoilPosts.Content.ReadAsAsync <List <KazHydrometSoilPost> >();
            }
            ViewBag.KazHydrometSoilPosts = new SelectList(kazHydrometSoilPosts.OrderBy(m => m.Name), "Id", "Name", targetTerritory.KazHydrometSoilPostId);

            List <TerritoryType> territoryTypes        = new List <TerritoryType>();
            string urlTerritoryTypes                   = "api/TerritoryTypes",
                   routeTerritoryTypes                 = "";
            HttpResponseMessage responseTerritoryTypes = await _HttpApiClient.GetAsync(urlTerritoryTypes + routeTerritoryTypes);

            if (responseTerritoryTypes.IsSuccessStatusCode)
            {
                territoryTypes = await responseTerritoryTypes.Content.ReadAsAsync <List <TerritoryType> >();
            }
            ViewBag.TerritoryTypes = new SelectList(territoryTypes.OrderBy(m => m.Name), "Id", "Name", targetTerritory.TerritoryTypeId);

            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", targetTerritory.KATOId);

            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", targetTerritory.ProjectId);

            ViewBag.CityDistrictCATO   = new SelectList(KATOes.Where(k => k.ParentEgovId == 17112).OrderBy(m => m.Name), "Id", "Code");
            ViewBag.CityDistrictNameKK = new SelectList(KATOes.Where(k => k.ParentEgovId == 17112).OrderBy(m => m.Name), "Id", "NameKK");
            ViewBag.CityDistrictNameRU = new SelectList(KATOes.Where(k => k.ParentEgovId == 17112).OrderBy(m => m.Name), "Id", "NameRU");

            ViewBag.City               = territoryTypes.FirstOrDefault(t => t.NameRU == Startup.Configuration["City"]).Id;
            ViewBag.CityDistrict       = territoryTypes.FirstOrDefault(t => t.NameRU == Startup.Configuration["CityDistrict"]).Id;
            ViewBag.OtherTerritoryType = territoryTypes.FirstOrDefault(t => t.NameRU == Startup.Configuration["OtherTerritoryType"]).Id;
            ViewBag.AlmatyCATO         = Startup.Configuration["AlmatyCATO"];
            ViewBag.AlmatyKK           = Startup.Configuration["AlmatyKK"];
            ViewBag.AlmatyRU           = Startup.Configuration["AlmatyRU"];

            return(View(targetTerritory));
        }