Refactor UpdateProfileProcedure and add MediatR handler

Refactored UpdateProfileProcedure to implement IUpdateProcedure and expanded its properties. Removed ToObjectProcedure method. Introduced UpdateProfileProcedureHandler using MediatR's ISender for command dispatch. Modernized structure to use record types and handler classes.
This commit is contained in:
2026-03-24 09:41:17 +01:00
parent 6b4897702a
commit acf136e689

View File

@@ -1,9 +1,11 @@
using MediatR;
using ReC.Application.Common.Procedures.UpdateProcedure; using ReC.Application.Common.Procedures.UpdateProcedure;
namespace ReC.Application.Profile.Commands; namespace ReC.Application.Profile.Commands;
public record UpdateProfileProcedure : IUpdateProcedure public record UpdateProfileProcedure : IUpdateProcedure
{ {
public long Id { get; set; }
public bool? Active { get; set; } public bool? Active { get; set; }
public byte? TypeId { get; set; } public byte? TypeId { get; set; }
public string? Mandantor { get; set; } public string? Mandantor { get; set; }
@@ -14,14 +16,17 @@ public record UpdateProfileProcedure : IUpdateProcedure
public DateTime? FirstRun { get; set; } public DateTime? FirstRun { get; set; }
public DateTime? LastRun { get; set; } public DateTime? LastRun { get; set; }
public string? LastResult { get; set; } public string? LastResult { get; set; }
}
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null) public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<UpdateProfileProcedure, int>
{
public async Task<int> Handle(UpdateProfileProcedure request, CancellationToken cancel)
{ {
return new UpdateObjectProcedure return await sender.Send(new UpdateObjectProcedure
{ {
Entity = "PROFILE", Entity = "PROFILE",
Id = id, Id = request.Id,
Profile = this Profile = request
}.ChangedBy(changedWho); }, cancel);
} }
} }