Refactor update procedures to use DTO-based pattern
Refactored Update*Procedure records to encapsulate update data in dedicated DTOs (e.g., UpdateActionDto, UpdateEndpointDto) via a generic Data property. Updated interfaces to be generic and modified handlers to pass only the DTO to UpdateObjectProcedure. This improves maintainability, reduces duplication, and standardizes update logic across entities.
This commit is contained in:
@@ -1,22 +1,14 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.EndpointAuth.Commands;
|
||||
|
||||
public record UpdateEndpointAuthProcedure : IUpdateProcedure
|
||||
public record UpdateEndpointAuthProcedure : IUpdateProcedure<UpdateEndpointAuthDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public byte? TypeId { get; set; }
|
||||
public string? ApiKey { get; set; }
|
||||
public string? ApiValue { get; set; }
|
||||
public bool? ApiKeyAddToId { get; set; }
|
||||
public string? Token { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public string? Password { get; set; }
|
||||
public string? Domain { get; set; }
|
||||
public string? Workstation { get; set; }
|
||||
|
||||
public UpdateEndpointAuthDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointAuthProcedure, int>
|
||||
@@ -27,7 +19,7 @@ public class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandle
|
||||
{
|
||||
Entity = "ENDPOINT_AUTH",
|
||||
Id = request.Id,
|
||||
EndpointAuth = request
|
||||
EndpointAuth = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user