Exemplo n.º 1
0
        public IList <IEmployeesDTO> SearchEmployee(IEmployeesDTO searchEmployeeDTO, bool checkTerminationDate)
        {
            IList <IEmployeesDTO> retVal = null;

            try
            {
                using (EmployeePortalEntities portal = new EmployeePortalEntities())
                {
                    IList <Employee> employeeList = new List <Employee>();
                    employeeList = portal.SearchEmployee(searchEmployeeDTO.FirstName,
                                                         searchEmployeeDTO.LastName,
                                                         searchEmployeeDTO.Email,
                                                         searchEmployeeDTO.DateOfJoining,
                                                         searchEmployeeDTO.TerminationDate,
                                                         searchEmployeeDTO.DepartmentId,
                                                         checkTerminationDate).ToList();

                    if (employeeList.Count > 0)
                    {
                        retVal = new List <IEmployeesDTO>();
                        foreach (var employee in employeeList)
                        {
                            IEmployeesDTO employeeDTO = (IEmployeesDTO)DTOFactory.Instance.Create(DTOType.EmployeeDTO);
                            EntityConverter.FillDTOFromEntity(employee, employeeDTO);
                            retVal.Add(employeeDTO);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(retVal);
        }