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:
@@ -1,3 +1,4 @@
|
|||||||
|
using MediatR;
|
||||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||||
|
|
||||||
namespace ReC.Application.Profile.Commands;
|
namespace ReC.Application.Profile.Commands;
|
||||||
@@ -18,15 +19,18 @@ public record DeleteProfileProcedure : 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 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",
|
Entity = "PROFILE",
|
||||||
Start = Start,
|
Start = request.Start,
|
||||||
End = End,
|
End = request.End,
|
||||||
Force = Force
|
Force = request.Force
|
||||||
};
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user