public ActionResult Createe(Consulatation c) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:8081"); client.PostAsJsonAsync <Consulatation>("SpringMVC/servlet/add-auto-consultation", c).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode()); return(RedirectToAction("Index")); }
public ActionResult Edit(Consulatation c) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:8081"); var putTask = client.PutAsJsonAsync <Consulatation>("SpringMVC/servlet/modify-Consultation", c); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(View(c)); } }
public ActionResult Edit(int id) { Consulatation c = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:8081"); var responseTask = client.GetAsync("SpringMVC/servlet/retrieve-consultation/" + id); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <Consulatation>(); readTask.Wait(); c = readTask.Result; } } return(View(c)); }
public ActionResult Delete(int id) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:8081"); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync("SpringMVC/servlet/remove-consultation/" + id).Result; Consulatation a = new Consulatation(); if (response.IsSuccessStatusCode) { a = response.Content.ReadAsAsync <Consulatation>().Result; } else { a = null; } return(View(a)); }