示例#1
0
        public static List <EmployeeViewModel> GetEmployeesInformation()
        {
            try
            {
                string data = ApiConnection.GetEmployeesFromApi();
                if (string.IsNullOrEmpty(data))
                {
                    return(employeesViewModel);
                }

                List <EmployeeProperties> employeesProperties = JsonConvert.DeserializeObject <List <EmployeeProperties> >(data);
                employeesViewModel = new List <EmployeeViewModel>();

                foreach (var item in employeesProperties)
                {
                    EmployeeDTO employeeDTO = employeeDTO = EmployeeFactory.FactoryMethod(item.ContractTypeName);
                    employeeDTO.EmployeeProperties = item;

                    EmployeeViewModel e = new EmployeeViewModel(employeeDTO.EmployeeProperties)
                    {
                        AnualSalary = employeeDTO.CalculatedAnualSalary()
                    };

                    employeesViewModel.Add(e);
                }

                return(employeesViewModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }