public static async Task <IList <Claim> > xGetClaimsAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, TUser user, CancellationToken cancellationToken = default) where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey> where TKey : IEquatable <TKey> where TUser : class, IIdentityUserWithClaims <TKey> where TUserClaim : class, IIdentityUserClaim <TKey> { store.ThrowIfCancelledRequestOrDisposedOrUserNull(user, cancellationToken); return(await store.Context.DbGetQueryable <TUserClaim>().xGetClaimsAsync(user, cancellationToken)); }
public static Task xAddClaimsAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, TUser user, IEnumerable <Claim> claims, CancellationToken cancellationToken = default) where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey> where TKey : IEquatable <TKey> where TUser : class, IIdentityUserWithClaims <TKey> where TUserClaim : class, IIdentityUserClaim <TKey>, new() { store.ThrowIfCancelledRequestOrDisposedOrUserNull(user, cancellationToken); if (claims == null) { throw new ArgumentNullException(nameof(claims)); } foreach (var claim in claims) { store.Context.DbInsertAsync(user.xCreateUserClaim <TKey, TUserClaim>(claim)); } return(Task.FromResult(false)); }
public static async Task xRemoveClaimsAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, TUser user, IEnumerable <Claim> claims, CancellationToken cancellationToken = default) where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey> where TKey : IEquatable <TKey> where TUser : class, IIdentityUserWithClaims <TKey> where TUserClaim : class, IIdentityUserClaim <TKey> { store.ThrowIfCancelledRequestOrDisposedOrUserNull(user, cancellationToken); if (claims == null) { throw new ArgumentNullException(nameof(claims)); } foreach (var claim in claims) { var matchedClaims = await store.Context.DbGetQueryable <TUserClaim>().Where(user, claim).xToListAsync(cancellationToken); foreach (var c in matchedClaims) { await store.Context.DbDeleteAsync(c); } } }
public static async Task xReplaceClaimAsync <TContext, TUser, TKey, TUserClaim>(this IIdentityUserClaimStoreWithContext <TContext, TUser, TKey, TUserClaim> store, TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken = default) where TContext : class, IIdentityContext//, IIdentityContext_WithUserClaims<TKey> where TKey : IEquatable <TKey> where TUser : class, IIdentityUserWithClaims <TKey> where TUserClaim : class, IIdentityUserClaim <TKey> { store.ThrowIfCancelledRequestOrDisposedOrUserNull(user, cancellationToken); if (claim == null) { throw new ArgumentNullException(nameof(claim)); } if (newClaim == null) { throw new ArgumentNullException(nameof(newClaim)); } var matchedClaims = await(store.Context.DbGetQueryable <TUserClaim>().Where(user, claim).Where(user, claim)).xToListAsync(cancellationToken); foreach (var matchedClaim in matchedClaims) { matchedClaim.ClaimValue = newClaim.Value; matchedClaim.ClaimType = newClaim.Type; } }