Refactor UpdateEndpointAuthProcedure and add handler

Expanded UpdateEndpointAuthProcedure with new properties and removed the ToObjectProcedure method. Introduced UpdateEndpointAuthProcedureHandler using MediatR's ISender for command handling, improving separation of concerns and enabling dependency injection.
This commit is contained in:
2026-03-24 09:59:21 +01:00
parent ee1f6a8753
commit a40f20f6d9

View File

@@ -1,9 +1,11 @@
using MediatR;
using ReC.Application.Common.Procedures.UpdateProcedure; using ReC.Application.Common.Procedures.UpdateProcedure;
namespace ReC.Application.EndpointAuth.Commands; namespace ReC.Application.EndpointAuth.Commands;
public record UpdateEndpointAuthProcedure : IUpdateProcedure public record UpdateEndpointAuthProcedure : IUpdateProcedure
{ {
public long Id { get; set; }
public bool? Active { get; set; } public bool? Active { get; set; }
public string? Description { get; set; } public string? Description { get; set; }
public byte? TypeId { get; set; } public byte? TypeId { get; set; }
@@ -15,14 +17,17 @@ public record UpdateEndpointAuthProcedure : IUpdateProcedure
public string? Password { get; set; } public string? Password { get; set; }
public string? Domain { get; set; } public string? Domain { get; set; }
public string? Workstation { get; set; } public string? Workstation { get; set; }
}
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null) public class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointAuthProcedure, int>
{
public async Task<int> Handle(UpdateEndpointAuthProcedure request, CancellationToken cancel)
{ {
return new UpdateObjectProcedure return await sender.Send(new UpdateObjectProcedure
{ {
Entity = "ENDPOINT_AUTH", Entity = "ENDPOINT_AUTH",
Id = id, Id = request.Id,
EndpointAuth = this EndpointAuth = request
}.ChangedBy(changedWho); }, cancel);
} }
} }