// GET: PlantationsTypes/Delete/5 public async Task <IActionResult> Delete(int?id, string SortOrder, string NameKKFilter, string NameRUFilter, string NameENFilter, int?PageSize, int?PageNumber) { ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.PageNumber = PageNumber; ViewBag.NameKKFilter = NameKKFilter; ViewBag.NameRUFilter = NameRUFilter; ViewBag.NameENFilter = NameENFilter; if (id == null) { return(NotFound()); } PlantationsType plantationsType = null; HttpResponseMessage response = await _HttpApiClient.GetAsync($"api/PlantationsTypes/{id.ToString()}"); if (response.IsSuccessStatusCode) { plantationsType = await response.Content.ReadAsAsync <PlantationsType>(); } if (plantationsType == null) { return(NotFound()); } return(View(plantationsType)); }
public async Task <ActionResult <PlantationsType> > PostPlantationsType(PlantationsType plantationsType) { _context.PlantationsType.Add(plantationsType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPlantationsType", new { id = plantationsType.Id }, plantationsType)); }
public async Task <IActionResult> PutPlantationsType(int id, PlantationsType plantationsType) { if (id != plantationsType.Id) { return(BadRequest()); } _context.Entry(plantationsType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlantationsTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,NameKK,NameRU,NameEN")] PlantationsType plantationsType, string SortOrder, string NameKKFilter, string NameRUFilter, string NameENFilter, int?PageSize, int?PageNumber) { ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.PageNumber = PageNumber; ViewBag.NameKKFilter = NameKKFilter; ViewBag.NameRUFilter = NameRUFilter; ViewBag.NameENFilter = NameENFilter; if (id != plantationsType.Id) { return(NotFound()); } if (ModelState.IsValid) { HttpResponseMessage response = await _HttpApiClient.PutAsJsonAsync( $"api/PlantationsTypes/{plantationsType.Id}", plantationsType); 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(plantationsType)); } plantationsType = await response.Content.ReadAsAsync <PlantationsType>(); return(RedirectToAction(nameof(Index), new { SortOrder = ViewBag.SortOrder, PageSize = ViewBag.PageSize, PageNumber = ViewBag.PageNumber, NameKKFilter = ViewBag.NameKKFilter, NameRUFilter = ViewBag.NameRUFilter, NameENFilter = ViewBag.NameENFilter })); } return(View(plantationsType)); }