public ActionResult Edit(mvcEHContactModel contact) { var putTask = GlobalVariables.WebApiClient.PutAsJsonAsync <mvcEHContactModel>("EHContacts", contact); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(View(contact)); }
public ActionResult create(mvcEHContactModel EHContact) { var postTask = GlobalVariables.WebApiClient.PostAsJsonAsync <mvcEHContactModel>("EHContacts", EHContact); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); return(View(EHContact)); }
public ActionResult Edit(int id) { mvcEHContactModel contact = null; var responseTask = GlobalVariables.WebApiClient.GetAsync("EHContacts?id=" + id.ToString()); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <mvcEHContactModel>(); readTask.Wait(); contact = readTask.Result; } return(View(contact)); }