public ActionResult Edit(int id) { UpdateInform ViewModel = new UpdateInform(); string url = "InformData/FindInform/" + id; HttpResponseMessage response = client.GetAsync(url).Result; //Can catch the status code (200 OK, 301 REDIRECT), etc. Debug.WriteLine(response.StatusCode); if (response.IsSuccessStatusCode) { InformDto SelectedInform = response.Content.ReadAsAsync <InformDto>().Result; ViewModel.Inform = SelectedInform; url = "ProjectData/GetProjects"; response = client.GetAsync(url).Result; IEnumerable <ProjectDto> InformsProject = response.Content.ReadAsAsync <IEnumerable <ProjectDto> >().Result; ViewModel.Allprojects = InformsProject; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public ActionResult Create() { UpdateInform ViewModel = new UpdateInform(); //get information about Projects this Inform is in. string url = "ProjectData/GetProjects"; HttpResponseMessage response = client.GetAsync(url).Result; IEnumerable <ProjectDto> PotetnialProjects = response.Content.ReadAsAsync <IEnumerable <ProjectDto> >().Result; ViewModel.Allprojects = PotetnialProjects; return(View(ViewModel)); }