feat: add Logs

This commit is contained in:
2026-09-20 16:21:15 +07:00
parent 637ca51f47
commit d3c3ecd5e6
62 changed files with 1577 additions and 66 deletions
@@ -1,12 +1,18 @@
using MediatR;
using mws.backend.dotnet.application.Audit;
using mws.backend.dotnet.application.Common;
using mws.backend.dotnet.application.Permissions;
namespace mws.backend.dotnet.application.Documents;
public record DeleteDocumentCommand(Guid UserId, Guid DocumentId) : IRequest;
public record DeleteDocumentCommand(Guid UserId, Guid DocumentId) : IRequest, IAuditableRequest
{
public string Action => "Document.Delete";
public string EntityType => "Document";
public Guid? EntityId => DocumentId;
}
public class DeleteDocumentHandler(IUnitOfWork uow, IDocumentContentStore contentStore)
public class DeleteDocumentHandler(IUnitOfWork uow, IDocumentContentStore contentStore, IAuditContext auditContext)
: IRequestHandler<DeleteDocumentCommand>
{
public async Task Handle(DeleteDocumentCommand command, CancellationToken ct)
@@ -25,6 +31,8 @@ public class DeleteDocumentHandler(IUnitOfWork uow, IDocumentContentStore conten
uow.Documents.Remove(doc);
await uow.SaveChangesAsync(ct);
auditContext.EntityName = doc.Title;
foreach (var key in keys)
{
await contentStore.DeleteAsync(key, ct);