Пример #1
0
        public List <Team> GetTeamList()
        {
            var teamList = (from team in _teamRepository.GetAll()
                            join user in _employeeRepository.GetAll() on team.TeamLeader equals user.EmployeeCode
                            join department in _departmentRepository.GetAll() on team.DepartmentID equals department.DeptCode1
                            select new
            {
                Id = team.Id,
                TeamName = team.TeamName,
                TeamLeader = team.TeamLeader,
                TeamLeaderName = user.EmployeeName + "(" + user.EmployeeCode + ")",
                DepartmentID = team.DepartmentID,
                DepartmentName = department.FullDeptName + "(" + department.DeptCode1 + ")"
            }).ToList();

            var list = new List <Team>();

            teamList.ForEach(team =>
            {
                list.Add(new Team
                {
                    Id             = team.Id,
                    TeamName       = team.TeamName,
                    TeamLeader     = team.TeamLeader,
                    TeamLeaderName = team.TeamLeaderName,
                    DepartmentID   = team.DepartmentID,
                    DepartmentName = team.DepartmentName
                });
            });

            return(list);
        }
Пример #2
0
        public List <HREmployee> GetEmployeeList(string searchTerm, int pageSize, int pageNum, out int totalCount)
        {
            var current_date  = DateTime.Now;
            var tomorrow_date = current_date.AddDays(1);

            totalCount = _employeeRepository.GetAll()
                         .Where(
                x => (string.IsNullOrEmpty(searchTerm) || x.EmployeeName.Contains(searchTerm) || x.EmployeeCode.Contains(searchTerm)) &&
                current_date > x.EntryDate && current_date < (x.ExitDate ?? tomorrow_date)
                ).Count();

            var employeeList = (from user in _employeeRepository.GetAll()
                                join department in _departmentRepository.GetAll() on user.DeptCode equals department.DeptCode1
                                where (string.IsNullOrEmpty(searchTerm) || user.EmployeeName.Contains(searchTerm) || user.EmployeeCode.Contains(searchTerm)) &&
                                current_date > user.EntryDate && current_date < (user.ExitDate ?? tomorrow_date)
                                orderby user.EmployeeName
                                select new {
                EmployeeCode = user.EmployeeCode,
                EmployeeName = user.EmployeeName,
                DeptCode = user.DeptCode,
                DeptName = department.DeptName1,
                EntryDate = user.EntryDate,
                ExitDate = user.ExitDate
            }).Skip((pageNum - 1) * pageSize).Take(pageSize).ToList();

            var list = new List <HREmployee>();

            employeeList.ForEach(x =>
            {
                list.Add(new HREmployee
                {
                    EmployeeCode = x.EmployeeCode,
                    EmployeeName = x.EmployeeName,
                    DeptCode     = x.DeptCode,
                    DeptName     = x.DeptName,
                    EntryDate    = x.EntryDate,
                    ExitDate     = x.ExitDate
                });
            });

            return(list);
        }
Пример #3
0
        public List <HRDepartment> GetRoleDepartments(int roleId)
        {
            var roleDepartmentIds = _roleDepartmentRepository.GetAll().Where(x => x.RoleId == roleId).Select(x => x.DepartmentId).ToList();

            return(_departmentRepository.GetAll().Where(x => roleDepartmentIds.Contains(x.DeptCode1)).ToList());
        }