// GET: JobPosting/Details/5 public ActionResult Details(int id) { ShowJobPosting ViewModel = new ShowJobPosting(); ViewModel.isadmin = User.IsInRole("Admin"); string url = "jobpostingdata/findjobposting/" + id; HttpResponseMessage response = client.GetAsync(url).Result; //Can catch the status code (200 OK, 301 REDIRECT), etc. Debug.WriteLine("Details:" + response.StatusCode); if (response.IsSuccessStatusCode) { //Put data into department data transfer object JobPostingDto SelectedJobPosting = response.Content.ReadAsAsync <JobPostingDto>().Result; ViewModel.jobposting = SelectedJobPosting; url = "jobpostingdata/finddepartmentforjobposting/" + id; response = client.GetAsync(url).Result; DepartmentDto SelectedDepartment = response.Content.ReadAsAsync <DepartmentDto>().Result; ViewModel.department = SelectedDepartment; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public ActionResult Details(int id) { ShowJobPosting ViewModel = new ShowJobPosting(); string url = "jobpostingdata/findpost/" + id; HttpResponseMessage response = client.GetAsync(url).Result; // If the response is a success, proceed if (response.IsSuccessStatusCode) { // Fetch the response content into IEnumerable<JobPostingDto> JobPostingDto SelectedPost = response.Content.ReadAsAsync <JobPostingDto>().Result; ViewModel.JobPosting = SelectedPost; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }