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:
2026-03-24 11:09:46 +01:00
parent 114b5de71d
commit eff6350d77
6 changed files with 30 additions and 59 deletions

View File

@@ -1,17 +1,14 @@
using MediatR;
using ReC.Application.Common.Procedures.UpdateProcedure;
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
namespace ReC.Application.EndpointParams.Commands;
public record UpdateEndpointParamsProcedure : IUpdateProcedure
public record UpdateEndpointParamsProcedure : IUpdateProcedure<UpdateEndpointParamsDto>
{
public long Id { get; set; }
public bool? Active { get; set; }
public string? Description { get; set; }
public short? GroupId { get; set; }
public byte? Sequence { get; set; }
public string? Key { get; set; }
public string? Value { get; set; }
public UpdateEndpointParamsDto Data { get; set; } = null!;
}
public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointParamsProcedure, int>
@@ -22,7 +19,7 @@ public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHand
{
Entity = "ENDPOINT_PARAMS",
Id = request.Id,
EndpointParams = request
EndpointParams = request.Data
}, cancel);
}
}