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.
25 lines
733 B
C#
25 lines
733 B
C#
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 class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointProcedure, int>
|
|
{
|
|
public async Task<int> Handle(UpdateEndpointProcedure request, CancellationToken cancel)
|
|
{
|
|
return await sender.Send(new UpdateObjectProcedure
|
|
{
|
|
Entity = "ENDPOINT",
|
|
Id = request.Id,
|
|
Endpoint = request
|
|
}, cancel);
|
|
}
|
|
} |