Example #1
0
        //GET api/EmployeeInfoAPI/5
        public HttpResponseMessage GetEmployeeInfo(int id)
        {
            // INTERVIEW_TODO: 2. Return the Employee or a Not Found (404) response if the ID is not valid
            // Details:
            // Use the  EmployeeInfoService to find the employee, and return one of the following:
            // The full EmployeeInfo object if it exists OR HttpStatusCode.NotFound

            var employee = _service.FindEmployee(id);

            if (employee?.EmpNo > default(int))
            {
                return(Request.CreateResponse(HttpStatusCode.OK, employee));
            }

            return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee Not Found"));
        }