public ActionResult Edit(int id, FormCollection collection) { EditEcard ViewModel = new EditEcard(); string url = "ecardsdara/findecard" + id; HttpResponseMessage response = client.GetAsync(url).Result; //Can catch the status code (200 OK, 301 REDIRECT), etc. //Debug.WriteLine(response.StatusCode); if (response.IsSuccessStatusCode) { //Put data into contact data transfer object EcardsDto SelectedEcards = response.Content.ReadAsAsync <EcardsDto>().Result; ViewModel.ecards = SelectedEcards; //get information about departments this ecard belongs to. url = "departmentsdata/getdepartments"; response = client.GetAsync(url).Result; IEnumerable <DepartmentsDto> PotentialContact = response.Content.ReadAsAsync <IEnumerable <DepartmentsDto> >().Result; ViewModel.alldepartments = PotentialContact; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public ActionResult Create() { EditEcard ViewModel = new EditEcard(); //get information about department this person COULD contact. string url = "contactsdata/getcontacts"; HttpResponseMessage response = client.GetAsync(url).Result; IEnumerable <DepartmentsDto> PotentialContacts = response.Content.ReadAsAsync <IEnumerable <DepartmentsDto> >().Result; ViewModel.alldepartments = PotentialContacts; return(View(ViewModel)); }