Ejemplo n.º 1
0
 public string[] FindUsersInRole(string roleName, string usernameToMatch)
 {
     var usersDAL = new UsersDAL();
     var users = usersDAL.GetAllUsers();
     var listOfUsers = new List<string>();
     foreach (var user in users)
     {
         if(user.Name.Contains(usernameToMatch))
         {
             foreach (var role in user.Roles)
             {
                 if(role.Name == roleName)
                 {
                     listOfUsers.Add(user.Name);
                 }
             }
         }
     }
     return listOfUsers.ToArray();
 }
Ejemplo n.º 2
0
 public string[] GetUsersInRole(string roleName)
 {
     var usersDAL = new UsersDAL();
     var allUsers = usersDAL.GetAllUsers();
     var list = new List<string>();
     if (allUsers != null)
         foreach (var user in allUsers.Where(user => user.Roles != null))
         {
             list.AddRange(from role in user.Roles where role.Name == roleName select user.Id);
         }
     return list.ToArray();
 }