feat: add Logs
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
|
||||
namespace mws.backend.dotnet.application.MasterData;
|
||||
|
||||
public record CreateMasterDataCommand(SaveMasterDataRequest Request) : IRequest<MasterDataDto>;
|
||||
public record CreateMasterDataCommand(SaveMasterDataRequest Request) : IRequest<MasterDataDto>, IAuditableRequest
|
||||
{
|
||||
public string Action => "MasterData.Create";
|
||||
public string EntityType => "MasterData";
|
||||
public string? EntityName => Request.Label;
|
||||
}
|
||||
|
||||
public class CreateMasterDataHandler(IUnitOfWork uow, IMapper mapper) : IRequestHandler<CreateMasterDataCommand, MasterDataDto>
|
||||
{
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
using MediatR;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
|
||||
namespace mws.backend.dotnet.application.MasterData;
|
||||
|
||||
public record DeleteMasterDataCommand(Guid Id) : IRequest;
|
||||
public record DeleteMasterDataCommand(Guid Id) : IRequest, IAuditableRequest
|
||||
{
|
||||
public string Action => "MasterData.Delete";
|
||||
public string EntityType => "MasterData";
|
||||
public Guid? EntityId => Id;
|
||||
}
|
||||
|
||||
public class DeleteMasterDataHandler(IUnitOfWork uow) : IRequestHandler<DeleteMasterDataCommand>
|
||||
public class DeleteMasterDataHandler(IUnitOfWork uow, IAuditContext auditContext) : IRequestHandler<DeleteMasterDataCommand>
|
||||
{
|
||||
public async Task Handle(DeleteMasterDataCommand command, CancellationToken ct)
|
||||
{
|
||||
@@ -14,5 +20,7 @@ public class DeleteMasterDataHandler(IUnitOfWork uow) : IRequestHandler<DeleteMa
|
||||
|
||||
uow.MasterData.Remove(entry);
|
||||
await uow.SaveChangesAsync(ct);
|
||||
|
||||
auditContext.EntityName = entry.Label;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
|
||||
namespace mws.backend.dotnet.application.MasterData;
|
||||
|
||||
public record UpdateMasterDataCommand(Guid Id, SaveMasterDataRequest Request) : IRequest<MasterDataDto>;
|
||||
public record UpdateMasterDataCommand(Guid Id, SaveMasterDataRequest Request) : IRequest<MasterDataDto>, IAuditableRequest
|
||||
{
|
||||
public string Action => "MasterData.Update";
|
||||
public string EntityType => "MasterData";
|
||||
public Guid? EntityId => Id;
|
||||
public string? EntityName => Request.Label;
|
||||
}
|
||||
|
||||
public class UpdateMasterDataHandler(IUnitOfWork uow, IMapper mapper) : IRequestHandler<UpdateMasterDataCommand, MasterDataDto>
|
||||
{
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
|
||||
namespace mws.backend.dotnet.application.MasterData;
|
||||
|
||||
public class MasterDataDto
|
||||
public class MasterDataDto : IHasEntityId
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid EntityId => Id;
|
||||
public string Group { get; set; } = string.Empty;
|
||||
public string Label { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user