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:
@@ -1,23 +1,28 @@
|
|||||||
|
using MediatR;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
|
||||||
namespace ReC.Application.EndpointParams.Commands;
|
namespace ReC.Application.EndpointParams.Commands;
|
||||||
|
|
||||||
public record UpdateEndpointParamsProcedure : IUpdateProcedure
|
public record UpdateEndpointParamsProcedure : IUpdateProcedure
|
||||||
{
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
public bool? Active { get; set; }
|
public bool? Active { get; set; }
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
public short? GroupId { get; set; }
|
public short? GroupId { get; set; }
|
||||||
public byte? Sequence { get; set; }
|
public byte? Sequence { get; set; }
|
||||||
public string? Key { get; set; }
|
public string? Key { get; set; }
|
||||||
public string? Value { 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",
|
Entity = "ENDPOINT_PARAMS",
|
||||||
Id = id,
|
Id = request.Id,
|
||||||
EndpointParams = this
|
EndpointParams = request
|
||||||
}.ChangedBy(changedWho);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user