public ActionResult Edit(int id) { UpdateJobPosting ViewModel = new UpdateJobPosting(); string url = "jobpostingdata/findjobposting/" + id; HttpResponseMessage response = client.GetAsync(url).Result; //Can catch the status code (200 OK, 301 REDIRECT), etc. Debug.WriteLine("edit: " + response.StatusCode); if (response.IsSuccessStatusCode) { JobPostingDto SelectedJobPosting = response.Content.ReadAsAsync <JobPostingDto>().Result; ViewModel.jobposting = SelectedJobPosting; url = "departmentdata/getdepartments"; response = client.GetAsync(url).Result; IEnumerable <DepartmentDto> PotentialDepartments = response.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result; Debug.WriteLine("Jobposting before getDepartment:"); ViewModel.alldepartments = PotentialDepartments; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public ActionResult Edit(int id) { UpdateJobPosting ViewModel = new UpdateJobPosting(); string url = "jobpostingdata/findpost/" + 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 jobposting data transfer object JobPostingDto SelectedJobPostings = response.Content.ReadAsAsync <JobPostingDto>().Result; ViewModel.JobPosting = SelectedJobPostings; url = "DepartmentData/GetDepartments"; response = client.GetAsync(url).Result; IEnumerable <DepartmentDto> departments = response.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result; ViewModel.AllDepartments = departments; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public ActionResult Create() { UpdateJobPosting ViewModel = new UpdateJobPosting(); string url = "DepartmentData/GetDepartments"; HttpResponseMessage response = client.GetAsync(url).Result; IEnumerable <DepartmentDto> departments = response.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result; ViewModel.AllDepartments = departments; return(View(ViewModel)); }
public ActionResult Create() { UpdateJobPosting ViewModel = new UpdateJobPosting(); //get information about Department string url = "departmentdata/getdepartments"; HttpResponseMessage response = client.GetAsync(url).Result; IEnumerable <DepartmentDto> PotentialDepartments = response.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result; ViewModel.alldepartments = PotentialDepartments; return(View(ViewModel)); }