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:
@@ -1,20 +1,25 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
|
||||
namespace ReC.Application.Endpoints.Commands;
|
||||
|
||||
public record UpdateEndpointProcedure : IUpdateProcedure
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { 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",
|
||||
Id = id,
|
||||
Endpoint = this
|
||||
}.ChangedBy(changedWho);
|
||||
Id = request.Id,
|
||||
Endpoint = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user