Esempio n. 1
0
        public List <Employee> Get(int id)
        {
            try
            {
                ServiceRepository   serviceObj = new ServiceRepository();
                HttpResponseMessage response   = serviceObj.GetResponse("Employees");
                response.EnsureSuccessStatusCode();

                List <Employee> employees = response.Content.ReadAsAsync <List <Employee> >().Result;
                Employee        employee  = employees.Find(x => x.Id == id);
                employee.CalculatedAnnualSalary = FactoryEmployee.CalculateAnnualSalary(employee.ContractTypeName, employee.HourlySalary, employee.MonthlySalary);
                List <Employee> result = new List <Employee>
                {
                    employee
                };

                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error {0}", e.GetType());
                throw;
            }
        }
Esempio n. 2
0
        public List <Employee> Get()
        {
            //api/employees
            try
            {
                ServiceRepository   serviceObj = new ServiceRepository();
                HttpResponseMessage response   = serviceObj.GetResponse("Employees");
                response.EnsureSuccessStatusCode();

                List <Employee> employees = response.Content.ReadAsAsync <List <Employee> >().Result;

                foreach (var employee in employees)
                {
                    employee.CalculatedAnnualSalary = FactoryEmployee.CalculateAnnualSalary(employee.ContractTypeName, employee.HourlySalary, employee.MonthlySalary);
                }

                return(employees);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error {0}", e.GetType());
                throw;
            }
        }