27 lines
895 B
C#
27 lines
895 B
C#
using Tiku.Application.Backoffice;
|
|
using Tiku.Domain.Operations;
|
|
using Tiku.Infrastructure.Persistence;
|
|
|
|
namespace Tiku.Infrastructure.Backoffice;
|
|
|
|
internal sealed class OperationAuditService(IJobsOperationsPersistence dbContext) : IOperationAuditService
|
|
{
|
|
public async Task WriteAsync(
|
|
BackofficeOperationAuditCommand command,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
dbContext.AuditLogs.Add(new AuditLog
|
|
{
|
|
TenantId = command.TenantId,
|
|
ActorUserId = command.ActorUserId,
|
|
Action = command.Action.Trim(),
|
|
TargetType = command.TargetType?.Trim(),
|
|
TargetId = command.TargetId?.Trim(),
|
|
Details = command.Details,
|
|
IpAddress = command.IpAddress,
|
|
UserAgent = command.UserAgent
|
|
});
|
|
|
|
await dbContext.SaveChangesAsync(cancellationToken);
|
|
}
|
|
} |