public IEnumerable <UserDepartment> GetDepartmentManagers(int departmentId) { IEnumerable <UserDepartment> userDepartments = _userDepartmentRepository.FindAll( ud => !ud.IsDeleted && ud.DepartmentId == departmentId); var managers = new List <UserDepartment>(); foreach (var userDepartment in userDepartments) { foreach (UserRole role in _userRoleRepository.FindByUserId(userDepartment.UserId)) { if (role.Role.RoleTypeId == (int)FixedRoleType.DepartmentManager) { managers.Add(userDepartment); break; } } } return(managers); }