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,24 +1,14 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public record UpdateActionProcedure : IUpdateProcedure
|
||||
public record UpdateActionProcedure : IUpdateProcedure<UpdateActionDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long? ProfileId { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
public byte? Sequence { get; set; }
|
||||
public long? EndpointId { get; set; }
|
||||
public long? EndpointAuthId { get; set; }
|
||||
public short? EndpointParamsId { get; set; }
|
||||
public short? SqlConnectionId { get; set; }
|
||||
public byte? TypeId { get; set; }
|
||||
public string? PreSql { get; set; }
|
||||
public string? HeaderSql { get; set; }
|
||||
public string? BodySql { get; set; }
|
||||
public string? PostSql { get; set; }
|
||||
public byte? ErrorActionId { get; set; }
|
||||
|
||||
public UpdateActionDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<UpdateActionProcedure, int>
|
||||
@@ -29,7 +19,7 @@ public class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<Upda
|
||||
{
|
||||
Entity = "ACTION",
|
||||
Id = request.Id,
|
||||
Action = request
|
||||
Action = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user