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:
@@ -1,9 +1,11 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
|
||||
namespace ReC.Application.EndpointAuth.Commands;
|
||||
|
||||
public record UpdateEndpointAuthProcedure : IUpdateProcedure
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public byte? TypeId { get; set; }
|
||||
@@ -15,14 +17,17 @@ public record UpdateEndpointAuthProcedure : IUpdateProcedure
|
||||
public string? Password { get; set; }
|
||||
public string? Domain { 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",
|
||||
Id = id,
|
||||
EndpointAuth = this
|
||||
}.ChangedBy(changedWho);
|
||||
Id = request.Id,
|
||||
EndpointAuth = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user