예제 #1
0
        public void TestGetEmployeeById()
        {
            MASGlobalEmployeesManager mng = new MASGlobalEmployeesManager(apiEndpointTest);

            var employee = mng.GetEmployeeById(1);

            Assert.IsNotNull(employee);
            Assert.IsTrue(employee.id == 1);
        }
예제 #2
0
        public void TestGetEmployees()
        {
            MASGlobalEmployeesManager mng = new MASGlobalEmployeesManager(apiEndpointTest);

            var employees = mng.GetEmployees();

            Assert.IsNotNull(employees);
            Assert.IsTrue(employees.Count > 0);
        }
예제 #3
0
        // GET api/<controller>
        public List <EmployeeDTO> Get()
        {
            var masGlobalApiEndpoint = ConfigurationManager.AppSettings["MASGlobalApiEndpoint"];

            List <EmployeeDTO> _employees = null;

            try
            {
                MASGlobalEmployeesManager manager = new MASGlobalEmployeesManager(masGlobalApiEndpoint);

                _employees = manager.GetEmployees();
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(_employees);
        }
예제 #4
0
        // GET api/<controller>/5
        public EmployeeDTO Get(int id)
        {
            var masGlobalApiEndpoint = ConfigurationManager.AppSettings["MASGlobalApiEndpoint"];

            EmployeeDTO _theEmployee = null;

            try
            {
                MASGlobalEmployeesManager manager = new MASGlobalEmployeesManager(masGlobalApiEndpoint);

                _theEmployee = manager.GetEmployeeById(id);
            }
            catch (EmployeeNotFoundException notFoundEx)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(_theEmployee);
        }