public ActionResult Edit(PODetailViewModel PODetailViewModel) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:19450/api/PODETAILs"); //HTTP POST var putTask = client.PutAsJsonAsync <PODetailViewModel>("PODETAILs", PODetailViewModel); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View(PODetailViewModel)); }
public ActionResult Create(PODetailViewModel PODetailViewModel) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:19450/api/PODETAILs"); //HTTP POST var postTask = client.PostAsJsonAsync <PODetailViewModel>("PODETAILs", PODetailViewModel); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); return(View(PODetailViewModel)); }
public ActionResult Edit(string id) { PODetailViewModel PODetailViewModel = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:19450/api/"); //HTTP GET var responseTask = client.GetAsync("PODETAILs?id=" + id); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <PODetailViewModel>(); readTask.Wait(); PODetailViewModel = readTask.Result; } } return(View(PODetailViewModel)); }