Refactor InsertProfileProcedure to use MediatR handler

Refactored InsertProfileProcedure by removing the ToObjectProcedure method and introducing InsertProfileProcedureHandler, which implements IRequestHandler and delegates insert logic via MediatR's ISender. Updated using directives to include MediatR. This aligns profile insertion with the MediatR request/response pattern.
This commit is contained in:
2026-03-24 10:14:58 +01:00
parent 94da75ce37
commit a590ffd2dc

View File

@@ -1,4 +1,5 @@
using ReC.Application.Common.Procedures.InsertProcedure; using MediatR;
using ReC.Application.Common.Procedures.InsertProcedure;
namespace ReC.Application.Profile.Commands; namespace ReC.Application.Profile.Commands;
@@ -11,13 +12,16 @@ public record InsertProfileProcedure : IInsertProcedure
public string? Description { get; set; } public string? Description { get; set; }
public byte? LogLevelId { get; set; } public byte? LogLevelId { get; set; }
public short? LanguageId { get; set; } public short? LanguageId { get; set; }
}
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null) public class InsertProfileProcedureHandler(ISender sender) : IRequestHandler<InsertProfileProcedure, long>
{
public async Task<long> Handle(InsertProfileProcedure request, CancellationToken cancel)
{ {
return new InsertObjectProcedure return await sender.Send(new InsertObjectProcedure
{ {
Entity = "PROFILE", Entity = "PROFILE",
Profile = this Profile = request
}.AddedBy(addedWho); }, cancel);
} }
} }