Ejemplo n.º 1
0
        // GET: Employee/Details/5
        public ActionResult Details(int id)
        {
            ShowEmployee        ViewModel = new ShowEmployee();
            string              url       = "employeedata/findemployee/" + 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 job posting data transfer object
                EmployeeDto SelectedEmployee = response.Content.ReadAsAsync <EmployeeDto>().Result;
                ViewModel.employee = SelectedEmployee;


                url      = "employeedata/findjob_postingforemployee/" + id;
                response = client.GetAsync(url).Result;
                Job_PostingDto SelectedJob_Posting = response.Content.ReadAsAsync <Job_PostingDto>().Result;
                ViewModel.job_posting = SelectedJob_Posting;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        public IHttpActionResult FindJob_PostingForEmployee(int id)
        {
            //Finds the first job which has any job applicants
            //that match the input Employeeid
            Job_Posting Job_Posting = db.Job_Postings
                                      .Where(t => t.Employees.Any(p => p.EmployeeID == id))
                                      .FirstOrDefault();

            //if not found, return 404 status code.
            if (Job_Posting == null)
            {
                return(NotFound());
            }

            //put into a 'friendly object format'
            Job_PostingDto Job_PostingDto = new Job_PostingDto
            {
                JobID   = Job_Posting.JobID,
                JobName = Job_Posting.JobName
            };


            //pass along data as 200 status code OK response
            return(Ok(Job_PostingDto));
        }