Refactor UpdateActionProcedure and add handler class

Expanded UpdateActionProcedure with new properties and removed the ToObjectProcedure method. Introduced UpdateActionProcedureHandler using MediatR to handle update logic and delegate to UpdateObjectProcedure. Centralized update logic in the handler for better maintainability.
This commit is contained in:
2026-03-19 23:18:47 +01:00
parent 5afc1791b0
commit d1dd021952

View File

@@ -1,9 +1,11 @@
using MediatR;
using ReC.Application.Common.Procedures.UpdateProcedure;
namespace ReC.Application.RecActions.Commands;
public record UpdateActionProcedure : IUpdateProcedure
{
public long Id { get; set; }
public long? ProfileId { get; set; }
public bool? Active { get; set; }
public byte? Sequence { get; set; }
@@ -17,14 +19,17 @@ public record UpdateActionProcedure : IUpdateProcedure
public string? BodySql { get; set; }
public string? PostSql { get; set; }
public byte? ErrorActionId { get; set; }
}
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
public class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<UpdateActionProcedure, int>
{
public async Task<int> Handle(UpdateActionProcedure request, CancellationToken cancel)
{
return new UpdateObjectProcedure
return await sender.Send(new UpdateObjectProcedure
{
Entity = "ACTION",
Id = id,
Action = this
}.ChangedBy(changedWho);
Id = request.Id,
Action = request
}, cancel);
}
}
}