| | | 1 | | using ProjectTemplate.Infrastructure.Data.Entities; |
| | | 2 | | |
| | | 3 | | namespace ProjectTemplate.Infrastructure.Data.Auditing; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Stores application audit records in the local EF Core audit record table. |
| | | 7 | | /// </summary> |
| | | 8 | | public sealed class LocalApplicationAuditStore : IApplicationAuditStore |
| | | 9 | | { |
| | | 10 | | /// <inheritdoc /> |
| | | 11 | | public void Append( |
| | | 12 | | ApplicationDbContext dbContext, |
| | | 13 | | AuditRecord auditRecord) |
| | | 14 | | { |
| | 4 | 15 | | ArgumentNullException.ThrowIfNull(dbContext); |
| | 4 | 16 | | ArgumentNullException.ThrowIfNull(auditRecord); |
| | | 17 | | |
| | 4 | 18 | | _ = dbContext.AuditRecords.Add(auditRecord); |
| | 4 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <inheritdoc /> |
| | | 22 | | public async ValueTask AppendAsync( |
| | | 23 | | ApplicationDbContext dbContext, |
| | | 24 | | AuditRecord auditRecord, |
| | | 25 | | CancellationToken cancellationToken = default) |
| | | 26 | | { |
| | 44 | 27 | | ArgumentNullException.ThrowIfNull(dbContext); |
| | 44 | 28 | | ArgumentNullException.ThrowIfNull(auditRecord); |
| | 44 | 29 | | cancellationToken.ThrowIfCancellationRequested(); |
| | | 30 | | |
| | 44 | 31 | | _ = await dbContext.AuditRecords.AddAsync(auditRecord, cancellationToken).ConfigureAwait(false); |
| | 44 | 32 | | } |
| | | 33 | | } |