public ActionResult UpdateArea(int id) { List <States_TableMeta> StateList = new List <States_TableMeta>(); SelectList list = new SelectList(StateList, "States_ID", "States_Name"); ViewBag.List = list; Area_TableMeta Area_TableMeta = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:49993/api/Area_Table"); //HTTP GET var responseTask = client.GetAsync("Area_Table?id=" + id.ToString()); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <Area_TableMeta>(); readTask.Wait(); Area_TableMeta = readTask.Result; } } return(View(Area_TableMeta)); }
public ActionResult CreateArea(Area_TableMeta Area_TableMeta) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:49993/api/Area_Table"); var postTask = client.PostAsJsonAsync <Area_TableMeta>("Area_TableMeta", Area_TableMeta); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); return(View(Area_TableMeta)); }
public ActionResult UpdateArea(Area_TableMeta Area_TableMeta) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:49993/api/Area_Table"); //HTTP POST var putTask = client.PutAsJsonAsync <Area_TableMeta>("Area_Table", Area_TableMeta); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View(Area_TableMeta)); }