Refactor DeleteEndpointProcedure to use MediatR handler
Replaces the ToObjectProcedure method with a dedicated DeleteEndpointProcedureHandler implementing IRequestHandler. The handler uses MediatR's ISender to send DeleteObjectProcedure, improving separation of concerns and aligning with MediatR request/response patterns.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using MediatR;
|
||||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||||
|
|
||||||
namespace ReC.Application.Endpoints.Commands;
|
namespace ReC.Application.Endpoints.Commands;
|
||||||
@@ -18,15 +19,18 @@ public record DeleteEndpointProcedure : IDeleteProcedure
|
|||||||
/// If true, delete even if dependent ACTION data exists
|
/// If true, delete even if dependent ACTION data exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Force { get; set; }
|
public bool Force { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public DeleteObjectProcedure ToObjectProcedure()
|
public class DeleteEndpointProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointProcedure, int>
|
||||||
|
{
|
||||||
|
public async Task<int> Handle(DeleteEndpointProcedure request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
return new DeleteObjectProcedure
|
return await sender.Send(new DeleteObjectProcedure
|
||||||
{
|
{
|
||||||
Entity = "ENDPOINT",
|
Entity = "ENDPOINT",
|
||||||
Start = Start,
|
Start = request.Start,
|
||||||
End = End,
|
End = request.End,
|
||||||
Force = Force
|
Force = request.Force
|
||||||
};
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user