I am trying to replace our own Audit system with Audit.NET. I have checked the documentation for Audit.EntityFramework, https://github.com/thepirat000/Audit.NET/tree/master/src/Audit.EntityFramework, and it is not clear to me where the configuration setup should be added. Also, lets say I am building a ASP.NET CORE RestFUL API and need to keep track of users making changes by extracting user information from a JWT, how would I set that up with Audit.EntityFramework?
In the documentation there is the follow code snippet to configure audits for orders and tracking users :
Audit.Core.Configuration.Setup()
.UseEntityFramework(ef => ef
.AuditTypeExplicitMapper(m => m
.Map<Order, Audit_Order>()
.Map<OrderItem, Audit_OrderItem>()
.AuditEntityAction<IAudit>((evt, entry, auditEntity) =>
{
auditEntity.AuditDate = DateTime.UtcNow;
auditEntity.UserName = evt.Environment.UserName;
auditEntity.AuditAction = entry.Action; // Insert, Update, Delete
})
)
);
However, if I would add that in the Startup.cs it would not help track what each user is doing on each call made by different users on the different endpoints. Do you have any example of how I can do this using Audit.EntityFramework?
Thanks