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;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
@@ -18,13 +19,16 @@ public record InsertActionProcedure : IInsertProcedure
|
||||
public string? BodySql { get; set; }
|
||||
public string? PostSql { get; set; }
|
||||
public byte? ErrorActionId { get; set; }
|
||||
}
|
||||
|
||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
|
||||
public class InsertActionProcedureHandler(ISender sender) : IRequestHandler<InsertActionProcedure, long>
|
||||
{
|
||||
public async Task<long> Handle(InsertActionProcedure request, CancellationToken cancel)
|
||||
{
|
||||
return new InsertObjectProcedure
|
||||
return await sender.Send(new InsertObjectProcedure
|
||||
{
|
||||
Entity = "ACTION",
|
||||
Action = this
|
||||
}.AddedBy(addedWho);
|
||||
Action = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user