// GET: TreesByObjectTableOfTheBreedStateLists/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()); } TreesByObjectTableOfTheBreedStateList treesByObjectTableOfTheBreedStateList = null; HttpResponseMessage response = await _HttpApiClient.GetAsync($"api/TreesByObjectTableOfTheBreedStateLists/{id.ToString()}"); if (response.IsSuccessStatusCode) { treesByObjectTableOfTheBreedStateList = await response.Content.ReadAsAsync <TreesByObjectTableOfTheBreedStateList>(); } if (treesByObjectTableOfTheBreedStateList == null) { return(NotFound()); } return(View(treesByObjectTableOfTheBreedStateList)); }
// GET: TreesByObjectTableOfTheBreedStateLists/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; TreesByObjectTableOfTheBreedStateList treesByObjectTableOfTheBreedStateList = null; HttpResponseMessage response = await _HttpApiClient.GetAsync($"api/TreesByObjectTableOfTheBreedStateLists/{id.ToString()}"); if (response.IsSuccessStatusCode) { treesByObjectTableOfTheBreedStateList = await response.Content.ReadAsAsync <TreesByObjectTableOfTheBreedStateList>(); } if (treesByObjectTableOfTheBreedStateList.StateOfCSR15PlantationsTypeId == null) { treesByObjectTableOfTheBreedStateList.StateOfCSR15Type = true; } else { treesByObjectTableOfTheBreedStateList.StateOfCSR15Type = 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", treesByObjectTableOfTheBreedStateList.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", treesByObjectTableOfTheBreedStateList.GreemPlantsPassportId); return(View(treesByObjectTableOfTheBreedStateList)); }
// GET: TreesByObjectTableOfTheBreedStateLists/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"); TreesByObjectTableOfTheBreedStateList model = new TreesByObjectTableOfTheBreedStateList(); return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,GreemPlantsPassportId,PlantationsTypeId,StateOfCSR15PlantationsTypeId,StateOfCSR15_1,StateOfCSR15_2,StateOfCSR15_3,StateOfCSR15_4,StateOfCSR15_5,Quantity,StateOfCSR15Type")] TreesByObjectTableOfTheBreedStateList treesByObjectTableOfTheBreedStateList, 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 != treesByObjectTableOfTheBreedStateList.Id) { return(NotFound()); } if (ModelState.IsValid) { if (treesByObjectTableOfTheBreedStateList.StateOfCSR15Type) { treesByObjectTableOfTheBreedStateList.StateOfCSR15PlantationsTypeId = null; } else { treesByObjectTableOfTheBreedStateList.StateOfCSR15_1 = null; treesByObjectTableOfTheBreedStateList.StateOfCSR15_2 = null; treesByObjectTableOfTheBreedStateList.StateOfCSR15_3 = null; treesByObjectTableOfTheBreedStateList.StateOfCSR15_4 = null; treesByObjectTableOfTheBreedStateList.StateOfCSR15_5 = null; } HttpResponseMessage response = await _HttpApiClient.PutAsJsonAsync( $"api/TreesByObjectTableOfTheBreedStateLists/{treesByObjectTableOfTheBreedStateList.Id}", treesByObjectTableOfTheBreedStateList); 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(treesByObjectTableOfTheBreedStateList)); } treesByObjectTableOfTheBreedStateList = await response.Content.ReadAsAsync <TreesByObjectTableOfTheBreedStateList>(); 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", treesByObjectTableOfTheBreedStateList.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", treesByObjectTableOfTheBreedStateList.GreemPlantsPassportId); return(View(treesByObjectTableOfTheBreedStateList)); }
public async Task <ActionResult <TreesByObjectTableOfTheBreedStateList> > PostTreesByObjectTableOfTheBreedStateList(TreesByObjectTableOfTheBreedStateList treesByObjectTableOfTheBreedStateList) { _context.TreesByObjectTableOfTheBreedStateList.Add(treesByObjectTableOfTheBreedStateList); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTreesByObjectTableOfTheBreedStateList", new { id = treesByObjectTableOfTheBreedStateList.Id }, treesByObjectTableOfTheBreedStateList)); }
public async Task <IActionResult> PutTreesByObjectTableOfTheBreedStateList(int id, TreesByObjectTableOfTheBreedStateList treesByObjectTableOfTheBreedStateList) { if (id != treesByObjectTableOfTheBreedStateList.Id) { return(BadRequest()); } _context.Entry(treesByObjectTableOfTheBreedStateList).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TreesByObjectTableOfTheBreedStateListExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }