public async Task <EmployeeDto> GetEmployeeById(int id) { var emp = await repository.Get(id); return(new EmployeeDto { id = emp.id, roleName = emp.roleName, roleDescription = emp.roleDescription, hourlySalary = emp.hourlySalary, contractTypeName = emp.contractTypeName, monthlySalary = emp.monthlySalary, name = emp.name, roleId = emp.roleId, annualSalary = SalaryFactory.Get((ContractEmun)Enum.Parse(typeof(ContractEmun), emp.contractTypeName), emp.hourlySalary.Value, emp.monthlySalary.Value) }); }
public async Task <List <EmployeeDto> > GetEmployees() { List <EmployeeDto> employees = new List <EmployeeDto>(); var empls = await repository.GetAll(); //Automapper employees = empls.Select(s => new EmployeeDto { id = s.id, name = s.name, roleId = s.roleId, roleDescription = s.roleDescription, roleName = s.roleName, hourlySalary = s.hourlySalary, monthlySalary = s.monthlySalary, annualSalary = SalaryFactory.Get((ContractEmun)Enum.Parse(typeof(ContractEmun), s.contractTypeName), s.hourlySalary.Value, s.monthlySalary.Value) }).ToList(); return(employees); }