// GET: TreesByFacilityManagementMeasuresLists/Delete/5
        public async Task <IActionResult> Delete(int?id,
                                                 string SortOrder,
                                                 int?GreemPlantsPassportIdFilter,
                                                 int?PlantationsTypeIdFilter,
                                                 int?PageSize,
                                                 int?PageNumber)
        {
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber;
            ViewBag.GreemPlantsPassportIdFilter = GreemPlantsPassportIdFilter;
            ViewBag.PlantationsTypeIdFilter     = PlantationsTypeIdFilter;
            if (id == null)
            {
                return(NotFound());
            }

            TreesByFacilityManagementMeasuresList treesByFacilityManagementMeasuresList = null;
            HttpResponseMessage response = await _HttpApiClient.GetAsync($"api/TreesByFacilityManagementMeasuresLists/{id.ToString()}");

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

            return(View(treesByFacilityManagementMeasuresList));
        }
        // GET: TreesByFacilityManagementMeasuresLists/Edit/5
        public async Task <IActionResult> Edit(int?id,
                                               string SortOrder,
                                               int?GreemPlantsPassportIdFilter,
                                               int?PlantationsTypeIdFilter,
                                               int?PageSize,
                                               int?PageNumber)
        {
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber;
            ViewBag.GreemPlantsPassportIdFilter = GreemPlantsPassportIdFilter;
            ViewBag.PlantationsTypeIdFilter     = PlantationsTypeIdFilter;
            TreesByFacilityManagementMeasuresList treesByFacilityManagementMeasuresList = null;
            HttpResponseMessage response = await _HttpApiClient.GetAsync($"api/TreesByFacilityManagementMeasuresLists/{id.ToString()}");

            if (response.IsSuccessStatusCode)
            {
                treesByFacilityManagementMeasuresList = await response.Content.ReadAsAsync <TreesByFacilityManagementMeasuresList>();
            }

            if (treesByFacilityManagementMeasuresList.BusinessEventsPlantationsTypeId == null)
            {
                treesByFacilityManagementMeasuresList.BusinessEvents = true;
            }
            else
            {
                treesByFacilityManagementMeasuresList.BusinessEvents = false;
            }

            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", treesByFacilityManagementMeasuresList.PlantationsTypeId);

            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", treesByFacilityManagementMeasuresList.GreemPlantsPassportId);

            return(View(treesByFacilityManagementMeasuresList));
        }
        // GET: TreesByFacilityManagementMeasuresLists/Create
        public async Task <IActionResult> Create(string SortOrder,
                                                 int?GreemPlantsPassportIdFilter,
                                                 int?PlantationsTypeIdFilter,
                                                 int?PageSize,
                                                 int?PageNumber)
        {
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber;
            ViewBag.GreemPlantsPassportIdFilter = GreemPlantsPassportIdFilter;
            ViewBag.PlantationsTypeIdFilter     = PlantationsTypeIdFilter;

            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");

            TreesByFacilityManagementMeasuresList model = new TreesByFacilityManagementMeasuresList();

            return(View(model));
        }
示例#4
0
        public async Task <ActionResult <TreesByFacilityManagementMeasuresList> > PostTreesByFacilityManagementMeasuresList(TreesByFacilityManagementMeasuresList treesByFacilityManagementMeasuresList)
        {
            _context.TreesByFacilityManagementMeasuresList.Add(treesByFacilityManagementMeasuresList);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTreesByFacilityManagementMeasuresList", new { id = treesByFacilityManagementMeasuresList.Id }, treesByFacilityManagementMeasuresList));
        }
示例#5
0
        public async Task <IActionResult> PutTreesByFacilityManagementMeasuresList(int id, TreesByFacilityManagementMeasuresList treesByFacilityManagementMeasuresList)
        {
            if (id != treesByFacilityManagementMeasuresList.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,GreemPlantsPassportId,PlantationsTypeId,BusinessEventsPlantationsTypeId,SanitaryPruning,CrownFormation,SanitaryFelling,MaintenanceWork,Quantity,BusinessEvents")] TreesByFacilityManagementMeasuresList treesByFacilityManagementMeasuresList,
                                               string SortOrder,
                                               int?GreemPlantsPassportIdFilter,
                                               int?PlantationsTypeIdFilter,
                                               int?PageSize,
                                               int?PageNumber)
        {
            ViewBag.SortOrder  = SortOrder;
            ViewBag.PageSize   = PageSize;
            ViewBag.PageNumber = PageNumber;
            ViewBag.GreemPlantsPassportIdFilter = GreemPlantsPassportIdFilter;
            ViewBag.PlantationsTypeIdFilter     = PlantationsTypeIdFilter;
            if (id != treesByFacilityManagementMeasuresList.Id)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                if (treesByFacilityManagementMeasuresList.BusinessEvents)
                {
                    treesByFacilityManagementMeasuresList.BusinessEventsPlantationsTypeId = null;
                }
                else
                {
                    treesByFacilityManagementMeasuresList.SanitaryPruning = null;
                    treesByFacilityManagementMeasuresList.CrownFormation  = null;
                    treesByFacilityManagementMeasuresList.SanitaryFelling = null;
                }

                HttpResponseMessage response = await _HttpApiClient.PutAsJsonAsync(
                    $"api/TreesByFacilityManagementMeasuresLists/{treesByFacilityManagementMeasuresList.Id}", treesByFacilityManagementMeasuresList);

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

                treesByFacilityManagementMeasuresList = await response.Content.ReadAsAsync <TreesByFacilityManagementMeasuresList>();

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

            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", treesByFacilityManagementMeasuresList.PlantationsTypeId);

            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", treesByFacilityManagementMeasuresList.GreemPlantsPassportId);

            return(View(treesByFacilityManagementMeasuresList));
        }