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