feat: add Logs
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user