/// <summary> /// Returns a list of employees /// </summary> /// <param name="id">optional, it specifies an Id to filter by</param> /// <returns>Returns a list of EmployeeDTO objects</returns> public List <EmployeeDTO> GetEmployees(int?id) { var result = new List <EmployeeDTO>(); var factory = new EmployeeFactory(); var employees = _repository.GetAll(); if (id.HasValue) { employees = employees.Where(e => e.Id == id.Value).ToList(); } foreach (EmployeeModel e in employees) { var dto = factory.CreateEmployeeDTO(e); dto.CalculateYearSalary(); result.Add(dto); } return(result); }