示例#1
0
        public async Task <IActionResult> PutGreemPlantsPassport(int id, GreemPlantsPassport greemPlantsPassport)
        {
            if (id != greemPlantsPassport.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        // GET: GreemPlantsPassports/Edit/5
        public async Task<IActionResult> Edit(int? id,
            string SortOrder,
            string GreenObjectFilter,
            int? KATOIdFilter,
            int? PageSize,
            int? PageNumber)
        {
            ViewBag.SortOrder = SortOrder;
            ViewBag.PageSize = PageSize;
            ViewBag.PageNumber = PageNumber;
            ViewBag.GreenObjectFilter = GreenObjectFilter;
            ViewBag.KATOIdFilter = KATOIdFilter;
            GreemPlantsPassport greemPlantsPassport = null;
            HttpResponseMessage response = await _HttpApiClient.GetAsync($"api/GreemPlantsPassports/{id.ToString()}");
            if (response.IsSuccessStatusCode)
            {
                greemPlantsPassport = await response.Content.ReadAsAsync<GreemPlantsPassport>();
            }

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

            return View(greemPlantsPassport);
        }
        // GET: GreemPlantsPassports/Delete/5
        public async Task<IActionResult> Delete(int? id,
            string SortOrder,
            string GreenObjectFilter,
            int? KATOIdFilter,
            int? PageSize,
            int? PageNumber)
        {
            ViewBag.SortOrder = SortOrder;
            ViewBag.PageSize = PageSize;
            ViewBag.PageNumber = PageNumber;
            ViewBag.GreenObjectFilter = GreenObjectFilter;
            ViewBag.KATOIdFilter = KATOIdFilter;
            if (id == null)
            {
                return NotFound();
            }

            GreemPlantsPassport greemPlantsPassport = null;
            HttpResponseMessage response = await _HttpApiClient.GetAsync($"api/GreemPlantsPassports/{id.ToString()}");
            if (response.IsSuccessStatusCode)
            {
                greemPlantsPassport = await response.Content.ReadAsAsync<GreemPlantsPassport>();
            }
            if (greemPlantsPassport == null)
            {
                return NotFound();
            }

            return View(greemPlantsPassport);
        }
        public async Task<IActionResult> Create([Bind("Id,GreenObject,KATOId,NameOfPowersAttributed,NameOfRegistrationObject,LegalEntityUse,AccountNumber,NameAndLocation,PresenceOfHistoricalObject,GreenTotalAreaGa,Lawns,Flowerbeds,TracksAndPlatforms,Tree,Shrubs,SofasAndBenches,Urns,EquippedPlaygrounds,EquippedSportsgrounds,Monument,Toilets,OutdoorLighting,Billboards,OtherCapitalStructures,GreenTotalArea,AreaUnderGreenery,AreaUnderLawn,AreaUnderGroundlawn,AreaUnderOrdinarylawn,AreaUnderMeadowlawn,AreaUnderTrees,AreaUnderShrubs,AreaUndeFlowerbeds,AreaUndeTracksAndPlatforms,Asphalted,PavingBlocks,LengthOfTrays,AmountConiferousTrees,ListOfTreesConiferous,Upto10yearsConiferous,Betwen10_20yearsConiferous,Over10yearsConiferous,AmountDeciduousTrees,ListOfTreesDeciduous,Upto10yearsDeciduous,Betwen10_20yearsDeciduous,Over10yearsDeciduous,AmountFormedTrees,TotallAmountShrubs,AmountShrubs,LengthOfHedges,AmountEquippedPlaygrounds,AmountEquippedSportsgrounds,AmountSofasAndBenches,AmountBenches,AmountSofas,AmountArbours,AmountOutdoorLighting,AmountToilets,AmountMonument,AmountBillboards,ListOfTreesByObjectBreedsCondition,ListOfTreesByObjectEconomicMeasures,PassportGeneralInformation,NorthLatitude,EastLongitude")] GreemPlantsPassport greemPlantsPassport,
            string SortOrder,
            string GreenObjectFilter,
            int? KATOIdFilter,
            int? PageSize,
            int? PageNumber)
        {
            ViewBag.SortOrder = SortOrder;
            ViewBag.PageSize = PageSize;
            ViewBag.PageNumber = PageNumber;
            ViewBag.GreenObjectFilter = GreenObjectFilter;
            ViewBag.KATOIdFilter = KATOIdFilter;
            if (ModelState.IsValid)
            {
                HttpResponseMessage response = await _HttpApiClient.PostAsJsonAsync(
                    "api/GreemPlantsPassports", greemPlantsPassport);

                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(greemPlantsPassport);
                }

                return RedirectToAction(nameof(Index),
                    new
                    {
                        SortOrder = ViewBag.SortOrder,
                        PageSize = ViewBag.PageSize,
                        PageNumber = ViewBag.PageNumber,
                        GreenObjectFilter = ViewBag.GreenObjectFilter,
                        KATOIdFilter = ViewBag.KATOIdFilter
                    });
            }

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

            return View(greemPlantsPassport);
        }
示例#5
0
        public async Task <ActionResult <GreemPlantsPassport> > PostGreemPlantsPassport(GreemPlantsPassport greemPlantsPassport)
        {
            _context.GreemPlantsPassport.Add(greemPlantsPassport);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGreemPlantsPassport", new { id = greemPlantsPassport.Id }, greemPlantsPassport));
        }