Refactor UpdateEndpointParamsProcedure to MediatR pattern

Refactored UpdateEndpointParamsProcedure to include all relevant properties and removed the ToObjectProcedure method. Introduced UpdateEndpointParamsProcedureHandler using MediatR's IRequestHandler, delegating update logic via ISender. This improves code structure and maintainability.
This commit is contained in:
2026-03-24 10:11:55 +01:00
parent ed94415a33
commit 401d67de4c

View File

@@ -1,23 +1,28 @@
using MediatR;
using ReC.Application.Common.Procedures.UpdateProcedure;
namespace ReC.Application.EndpointParams.Commands;
public record UpdateEndpointParamsProcedure : IUpdateProcedure
{
public long Id { get; set; }
public bool? Active { get; set; }
public string? Description { get; set; }
public short? GroupId { get; set; }
public byte? Sequence { get; set; }
public string? Key { get; set; }
public string? Value { get; set; }
}
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointParamsProcedure, int>
{
public async Task<int> Handle(UpdateEndpointParamsProcedure request, CancellationToken cancel)
{
return new UpdateObjectProcedure
return await sender.Send(new UpdateObjectProcedure
{
Entity = "ENDPOINT_PARAMS",
Id = id,
EndpointParams = this
}.ChangedBy(changedWho);
Id = request.Id,
EndpointParams = request
}, cancel);
}
}
}