Refactor UpdateEndpointProcedure and add handler

Refactored UpdateEndpointProcedure to implement IUpdateProcedure directly and removed the ToObjectProcedure method. Introduced UpdateEndpointProcedureHandler using MediatR's ISender for command handling, aligning with MediatR patterns and enabling dependency injection.
This commit is contained in:
2026-03-24 10:13:35 +01:00
parent e31d034266
commit 9c1ffd7df8

View File

@@ -1,20 +1,25 @@
using MediatR;
using ReC.Application.Common.Procedures.UpdateProcedure; using ReC.Application.Common.Procedures.UpdateProcedure;
namespace ReC.Application.Endpoints.Commands; namespace ReC.Application.Endpoints.Commands;
public record UpdateEndpointProcedure : IUpdateProcedure public record UpdateEndpointProcedure : 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 string? Uri { get; set; } public string? Uri { get; set; }
}
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null) public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointProcedure, int>
{
public async Task<int> Handle(UpdateEndpointProcedure request, CancellationToken cancel)
{ {
return new UpdateObjectProcedure return await sender.Send(new UpdateObjectProcedure
{ {
Entity = "ENDPOINT", Entity = "ENDPOINT",
Id = id, Id = request.Id,
Endpoint = this Endpoint = request
}.ChangedBy(changedWho); }, cancel);
} }
} }