public static async Task <IList <Claim> > GetClaimsAsync(this IUsersClaimsRepository usersClaims,
                                                          Guid userId, CancellationToken cancellationToken = default)
 {
     cancellationToken.ThrowIfCancellationRequested();
     return((await usersClaims.ProcessQueryAsync(
                 usersClaims.AsQueryable()
                 .Where(x => x.UserId == userId),
                 cancellationToken)).Select(x => x.ToClaim()).ToList());
 }
 public static async Task <IReadOnlyCollection <UserClaim> > FindMatchedClaimsAsync(
     this IUsersClaimsRepository usersClaims,
     Guid userId, string value, string type, CancellationToken cancellationToken = default)
 {
     cancellationToken.ThrowIfCancellationRequested();
     return(await usersClaims.ProcessQueryAsync(
                usersClaims.AsQueryable()
                .Where(x => x.UserId == userId && x.ClaimValue == value && x.ClaimType == type),
                cancellationToken));
 }
 public static async Task <IReadOnlyCollection <User> > GetUsersForClaimAsync(
     this IUsersClaimsRepository usersClaims,
     Claim claim, IUsersRepository users, CancellationToken cancellationToken = default)
 {
     cancellationToken.ThrowIfCancellationRequested();
     return(await users.ProcessQueryAsync(
                usersClaims.AsQueryable()
                .Where(userClaim => userClaim.ClaimValue == claim.Value && userClaim.ClaimType == claim.Type)
                .Join(users.AsQueryable(), userClaim => userClaim.UserId, user => user.Id,
                      (userClaim, user) => user),
                cancellationToken));
 }