Add MediatR handler for DeleteProfileProcedure command

Introduce DeleteProfileProcedureHandler using MediatR's IRequestHandler to process DeleteProfileProcedure requests. The handler sends a DeleteObjectProcedure via ISender, replacing the previous ToObjectProcedure method. Also, add necessary using directives and refactor logic to centralize command handling.
This commit is contained in:
2026-03-24 10:14:10 +01:00
parent 9c1ffd7df8
commit 94da75ce37

View File

@@ -1,3 +1,4 @@
using MediatR;
using ReC.Application.Common.Procedures.DeleteProcedure;
namespace ReC.Application.Profile.Commands;
@@ -18,15 +19,18 @@ public record DeleteProfileProcedure : IDeleteProcedure
/// If true, delete even if dependent ACTION data exists
/// </summary>
public bool Force { get; set; }
}
public DeleteObjectProcedure ToObjectProcedure()
public class DeleteProfileProcedureHandler(ISender sender) : IRequestHandler<DeleteProfileProcedure, int>
{
public async Task<int> Handle(DeleteProfileProcedure request, CancellationToken cancel)
{
return new DeleteObjectProcedure
return await sender.Send(new DeleteObjectProcedure
{
Entity = "PROFILE",
Start = Start,
End = End,
Force = Force
};
Start = request.Start,
End = request.End,
Force = request.Force
}, cancel);
}
}