public ActionResult ListDoctors() { string URL = "DoctorData/GetDoctors"; List <ListDoctor> ViewModel = new List <ListDoctor>(); HttpResponseMessage httpResponse = Client.GetAsync(URL).Result; if (httpResponse.IsSuccessStatusCode) { IEnumerable <DoctorDTO> DoctorsList = httpResponse.Content.ReadAsAsync <IEnumerable <DoctorDTO> >().Result; foreach (var item in DoctorsList) { URL = "PracticeData/FindPractice/" + item.PracticeID; httpResponse = Client.GetAsync(URL).Result; PracticeDTO Practice = httpResponse.Content.ReadAsAsync <PracticeDTO>().Result; ListDoctor NewList = new ListDoctor { Doctor = item, Practice = Practice }; ViewModel.Add(NewList); } return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public ActionResult DeleteConfirm(int id) { string URL = "DoctorData/GetDoctor/" + id; ListDoctor ViewModel = new ListDoctor(); HttpResponseMessage HttpResponse = Client.GetAsync(URL).Result; if (HttpResponse.IsSuccessStatusCode) { DoctorDTO Doctor = HttpResponse.Content.ReadAsAsync <DoctorDTO>().Result; ViewModel.Doctor = Doctor; URL = "PracticeData/FindPractice/" + Doctor.PracticeID; HttpResponse = Client.GetAsync(URL).Result; PracticeDTO Practice = HttpResponse.Content.ReadAsAsync <PracticeDTO>().Result; ViewModel.Practice = Practice; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }