コード例 #1
0
 public static async Task <TRole> xFindByNameAsync <TContext, TRole, TKey>(this IIdentityRoleStoreWithContext <TContext, TRole, TKey> store, string normalizedName, CancellationToken cancellationToken = default)
     where TContext : class, IIdentityContext//, IIdentityContext_WithUserAndRoles<TKey>
     where TKey : IEquatable <TKey>
     where TRole : class, IIdentityRoleWithConcurrency <TKey>
 {
     store.ThrowIfCancelledRequestOrDisposed(cancellationToken);
     return((TRole)await store.Context.DbGetQueryable <TRole>().xFindByNameAsync(normalizedName, cancellationToken));
 }
コード例 #2
0
        public static async Task <IdentityResult> xUpdateAsync <TContext, TRole, TKey>(this IIdentityRoleStoreWithContext <TContext, TRole, TKey> store, TRole role, CancellationToken cancellationToken = default)
            where TContext : class, IIdentityContext//, IIdentityContext_WithUserAndRoles<TKey>
            where TKey : IEquatable <TKey>
            where TRole : class, IIdentityRoleWithConcurrency <TKey>
        {
            store.ThrowIfCancelledRequestOrDisposedOrRoleNull(role, cancellationToken);
            var stored = await store.Context.DbGetQueryable <TRole>().FindByIdAndConcurrencyStampAsync(role, cancellationToken);

            if (stored == null)
            {
                return(IdentityResult.Failed(store.ErrorDescriber.ConcurrencyFailure()));
            }
            role.ConcurrencyStamp = Guid.NewGuid().ToString();
            await store.Context.DbUpdateAsync(role, cancellationToken);

            return(IdentityResult.Success);
        }
コード例 #3
0
        public static async Task <IdentityResult> xCreateAsync <TContext, TRole, TKey>(this IIdentityRoleStoreWithContext <TContext, TRole, TKey> store, TRole role, CancellationToken cancellationToken = default)
            where TContext : class, IIdentityContext//, IIdentityContext_WithUserAndRoles<TKey>
            where TKey : IEquatable <TKey>
            where TRole : class, IIdentityRoleWithConcurrency <TKey>
        {
            store.ThrowIfCancelledRequestOrDisposedOrRoleNull(role, cancellationToken);
            await store.Context.DbInsertAsync(role, cancellationToken);

            return(IdentityResult.Success);
        }