示例#1
0
        public List <User> ReadUsers()
        {
            var eUsers = _iDUser.ReadUsers();
            var eRoles = _iDRoles.List <ERole>(a => true);

            return(eUsers.Select(a => new User
            {
                UserId = a.UserId,
                Username = a.Username,
                Firstname = a.Firstname,
                EmployeeId = a.EmployeeId,
                Status = a.Status,
                Roles = eRoles.Select(b =>
                                      new Role
                {
                    RoleId = b.RoleId,
                    RoleName = b.RoleName,
                    RoleStatus = a.UserRole.Any(c => c.RoleId == b.RoleId)
                }).ToList()
            }).ToList());
        }
示例#2
0
        public bool HasRole(int credentialId, string[] roles)
        {
            var eRoles = _iDRole.List <ERole>(a => a.CredentialRoles.Any(b => b.CredentialId == credentialId));

            return(eRoles.Any(a => roles.Contains(a.Name)));
        }