public static async Task <IReadOnlyCollection <Role> > GetRolesAsync(this IUsersRolesRepository usersRoles,
                                                                             Guid userId, IRolesRepository roles,
                                                                             CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var roleIdCollection = (await
                                    usersRoles.ProcessQueryAsync(usersRoles.AsQueryable().Where(x => x.UserId == userId),
                                                                 cancellationToken)).Select(x => x.RoleId);

            return(await roles.ProcessQueryAsync(roles.AsQueryable().Where(
                                                     role => roleIdCollection.Contains(role.Id)), cancellationToken));
        }
        public static async Task <IReadOnlyCollection <User> > GetUsersInRoleAsync(this IUsersRolesRepository usersRoles,
                                                                                   string roleName, IRolesRepository roles, IUsersRepository users,
                                                                                   CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var role = await roles.FindByNameAsync(roleName, false, cancellationToken);

            var userIdCollection = (await
                                    usersRoles.ProcessQueryAsync(usersRoles.AsQueryable().Where(x => x.RoleId == role.Id),
                                                                 cancellationToken)).Select(x => x.UserId);

            return(await users.ProcessQueryAsync(users.AsQueryable().Where(
                                                     user => userIdCollection.Contains(user.Id)), cancellationToken));
        }