Class AuditStore<TAudit, TContext>
Represents a new instance of a persistence store for IdentityAudit.
Inherited Members
Namespace: IRM.AspNetCore.Identity.EntityFrameworkCore
Assembly: IRM.AspNetCore.Identity.EntityFrameworkCore.dll
Syntax
public class AuditStore<TAudit, TContext> : IAuditStore<TAudit>, IDisposable where TAudit : class, IIdentityAudit, new()
where TContext : DbContext
Type Parameters
TAudit
The type representing an audit. |
TContext
The type of the data context class used to access the store. |
Constructors
AuditStore(TContext, ILogger<AuditStore<TAudit, TContext>>)
Creates a new instance of AuditStore<TAudit, TContext>.
Declaration
public AuditStore(TContext context, ILogger<AuditStore<TAudit, TContext>> logger)
Parameters
TContext
context
The context used to access the store. |
Microsoft.Extensions.Logging.ILogger<AuditStore<TAudit, TContext>>
logger
The logger used to log messages, warnings and errors. |
Properties
Audits
A navigation property for the audits the store contains.
Declaration
public virtual IQueryable<TAudit> Audits { get; }
Property Value
System.Linq.IQueryable<TAudit>
|
Context
Gets the database context for this store.
Declaration
public TContext Context { get; }
Property Value
TContext
|
Methods
ClearAuditsAsync(TimeSpan, CancellationToken)
Clears all audits (for all users) created before the provided maxAge
.
Declaration
public virtual Task ClearAuditsAsync(TimeSpan maxAge, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TimeSpan
maxAge
The max age of the audit posts to keep. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task
The System.Threading.Tasks.Task that represents the asynchronous operation. |
Implements
CreateAsync(TAudit, CancellationToken)
Creates the specified audit
in the audit store.
Declaration
public virtual async Task<IdentityResult> CreateAsync(TAudit audit, CancellationToken cancellationToken = default(CancellationToken))
Parameters
TAudit
audit
The audit to create. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the creation operation. |
Implements
CreateAudit()
Create a new entity representing an audit.
Declaration
public virtual TAudit CreateAudit()
Returns
TAudit
|
Implements
DeleteUserAuditsAsync(Guid, CancellationToken)
Deletes the audits for the user with the specified userId
from the backing store.
Declaration
public virtual async Task<IdentityResult> DeleteUserAuditsAsync(Guid userId, CancellationToken cancellationToken = default(CancellationToken))
Parameters
System.Guid
userId
The id of the user to delete all audits for. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the operation. |
Implements
Dispose()
Releases all resources used by the store.
Declaration
public void Dispose()
Implements
Dispose(Boolean)
Releases the unmanaged resources used by the audit store and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Boolean
disposing
true to release both managed and unmanaged resources; false to release only unmanaged resources. |
GetUserAuditsAsync(IdQuery, CancellationToken)
Returns a list of audits for the specified user id.
Declaration
public virtual Task<QueryResult<TAudit>> GetUserAuditsAsync(IdQuery query, CancellationToken cancellationToken = default(CancellationToken))
Parameters
IdQuery
query
The IdQuery object representing the user id and pageing information. |
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task<QueryResult<TAudit>>
The System.Threading.Tasks.Task that represents the asynchronous operation, a QueryResult<T> with a collection of |
Implements
SaveChanges(CancellationToken)
Saves the current store.
Declaration
protected virtual Task SaveChanges(CancellationToken cancellationToken)
Parameters
System.Threading.CancellationToken
cancellationToken
The System.Threading.CancellationToken used to propagate notifications that the operation should be canceled. |
Returns
System.Threading.Tasks.Task
The System.Threading.Tasks.Task that represents the asynchronous operation. |
ThrowIfDisposed()
Throws an System.ObjectDisposedException if the audit store is disposed.
Declaration
protected void ThrowIfDisposed()