public ActionResult Delete(int id) { PersonVM person = new PersonVM(); HttpResponseMessage response = PersonClientAPI.GetResponseFromAPI(id.ToString()); if (response.IsSuccessStatusCode) { person = response.Content.ReadAsAsync <PersonVM>().Result; } return(View(person)); }
public ActionResult Edit(int Id, PersonVM model) { try { PersonClientAPI.EditPerson(model.Id, model); return(RedirectToAction("Index")); } catch { return(View(model)); } }
public ActionResult Index() { IList <PersonVM> listPersons = new List <PersonVM>(); HttpResponseMessage response = PersonClientAPI.GetResponseFromAPI(); if (response.IsSuccessStatusCode) { var persons = response.Content.ReadAsAsync <IEnumerable <PersonVM> >().Result; listPersons = persons.ToList(); } return(View(listPersons)); }
public ActionResult Delete(int id, PersonVM person) { try { var response = PersonClientAPI.DeleteToAPI(id.ToString(), person); return(RedirectToAction("Index")); } catch { return(View()); } }
// POST: Person/Create public async Task <ActionResult> Create(PersonVM model) { try { await PersonClientAPI.PostToAPI(model); return(RedirectToAction("Index")); } catch { return(View()); } }