Refactor InsertActionProcedure to use MediatR handler
Replaces the ToObjectProcedure method with an InsertActionProcedureHandler that implements IRequestHandler using MediatR. The handler maps InsertActionProcedure to InsertObjectProcedure and sends it via ISender. Also updates using statements to include MediatR.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
using MediatR;
|
||||||
|
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||||
using ReC.Domain.Constants;
|
using ReC.Domain.Constants;
|
||||||
|
|
||||||
namespace ReC.Application.RecActions.Commands;
|
namespace ReC.Application.RecActions.Commands;
|
||||||
@@ -18,13 +19,16 @@ public record InsertActionProcedure : IInsertProcedure
|
|||||||
public string? BodySql { get; set; }
|
public string? BodySql { get; set; }
|
||||||
public string? PostSql { get; set; }
|
public string? PostSql { get; set; }
|
||||||
public byte? ErrorActionId { get; set; }
|
public byte? ErrorActionId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
|
public class InsertActionProcedureHandler(ISender sender) : IRequestHandler<InsertActionProcedure, long>
|
||||||
{
|
{
|
||||||
return new InsertObjectProcedure
|
public async Task<long> Handle(InsertActionProcedure request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
return await sender.Send(new InsertObjectProcedure
|
||||||
{
|
{
|
||||||
Entity = "ACTION",
|
Entity = "ACTION",
|
||||||
Action = this
|
Action = request
|
||||||
}.AddedBy(addedWho);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user