Refactor ChangedWho handling in UpdateObjectProcedure

ChangedWho is now initialized directly and no longer settable via a public method. Removed the ChangedBy method and related extension methods. Added a TODO to move ChangedWho assignment to authentication middleware in the future.
This commit is contained in:
2026-03-24 09:48:37 +01:00
parent 554aaa8b6c
commit e152e9a37a

View File

@@ -26,13 +26,8 @@ public record UpdateObjectProcedure : IRequest<int>
/// </summary> /// </summary>
public long Id { get; set; } public long Id { get; set; }
internal string? ChangedWho { get; private set; } //TODO: update to set in authentication middleware or similar, and remove from procedure properties
internal string? ChangedWho { get; private set; } = "ReC.API";
public UpdateObjectProcedure ChangedBy(string? changedWho = null)
{
ChangedWho = changedWho ?? "ReC.API";
return this;
}
public UpdateActionProcedure Action { get; set; } = new(); public UpdateActionProcedure Action { get; set; } = new();
public UpdateEndpointProcedure Endpoint { get; set; } = new(); public UpdateEndpointProcedure Endpoint { get; set; } = new();
@@ -42,14 +37,6 @@ public record UpdateObjectProcedure : IRequest<int>
public UpdateEndpointParamsProcedure EndpointParams { get; set; } = new(); public UpdateEndpointParamsProcedure EndpointParams { get; set; } = new();
} }
public static class UpdateObjectProcedureExtensions
{
public static Task<int> ExecuteUpdateProcedure(this ISender sender, IUpdateProcedure procedure, long id, string? changedWho = null, CancellationToken cancel = default)
{
return sender.Send(procedure.ToObjectProcedure(id, changedWho ?? "ReC.API"), cancel);
}
}
public class UpdateObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<UpdateObjectProcedure, int> public class UpdateObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<UpdateObjectProcedure, int>
{ {
public async Task<int> Handle(UpdateObjectProcedure request, CancellationToken cancel) public async Task<int> Handle(UpdateObjectProcedure request, CancellationToken cancel)