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); }
public static async Task <IdentityResult> xDeleteAsync <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())); } await store.Context.DbDeleteAsync(role, cancellationToken); return(IdentityResult.Success); }