feat: add Logs
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
using mws.backend.dotnet.domain.Roles;
|
||||
|
||||
namespace mws.backend.dotnet.application.Permissions;
|
||||
|
||||
public record CreateRoleCommand(SaveRoleRequest Request) : IRequest<RoleDto>;
|
||||
public record CreateRoleCommand(SaveRoleRequest Request) : IRequest<RoleDto>, IAuditableRequest
|
||||
{
|
||||
public string Action => "Role.Create";
|
||||
public string EntityType => "Role";
|
||||
public string? EntityName => Request.Name;
|
||||
}
|
||||
|
||||
public class CreateRoleHandler(IUnitOfWork uow, IMapper mapper) : IRequestHandler<CreateRoleCommand, RoleDto>
|
||||
{
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
using MediatR;
|
||||
using mws.backend.dotnet.application.Audit;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
|
||||
namespace mws.backend.dotnet.application.Permissions;
|
||||
|
||||
public record DeleteRoleCommand(Guid Id) : IRequest;
|
||||
public record DeleteRoleCommand(Guid Id) : IRequest, IAuditableRequest
|
||||
{
|
||||
public string Action => "Role.Delete";
|
||||
public string EntityType => "Role";
|
||||
public Guid? EntityId => Id;
|
||||
}
|
||||
|
||||
public class DeleteRoleHandler(IUnitOfWork uow) : IRequestHandler<DeleteRoleCommand>
|
||||
public class DeleteRoleHandler(IUnitOfWork uow, IAuditContext auditContext) : IRequestHandler<DeleteRoleCommand>
|
||||
{
|
||||
public async Task Handle(DeleteRoleCommand command, CancellationToken ct)
|
||||
{
|
||||
@@ -24,5 +30,7 @@ public class DeleteRoleHandler(IUnitOfWork uow) : IRequestHandler<DeleteRoleComm
|
||||
|
||||
uow.Roles.Remove(role);
|
||||
await uow.SaveChangesAsync(ct);
|
||||
|
||||
auditContext.EntityName = role.Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.Permissions;
|
||||
|
||||
public record UpdateRoleCommand(Guid Id, SaveRoleRequest Request) : IRequest<RoleDto>;
|
||||
public record UpdateRoleCommand(Guid Id, SaveRoleRequest Request) : IRequest<RoleDto>, IAuditableRequest
|
||||
{
|
||||
public string Action => "Role.Update";
|
||||
public string EntityType => "Role";
|
||||
public Guid? EntityId => Id;
|
||||
public string? EntityName => Request.Name;
|
||||
}
|
||||
|
||||
public class UpdateRoleHandler(IUnitOfWork uow, IMapper mapper) : IRequestHandler<UpdateRoleCommand, RoleDto>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user