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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.Endpoints.Commands;
|
||||
|
||||
public record UpdateEndpointProcedure : IUpdateProcedure
|
||||
public record UpdateEndpointProcedure : IUpdateProcedure<UpdateEndpointDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Uri { get; set; }
|
||||
|
||||
public UpdateEndpointDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointProcedure, int>
|
||||
@@ -19,7 +19,7 @@ public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<Up
|
||||
{
|
||||
Entity = "ENDPOINT",
|
||||
Id = request.Id,
|
||||
Endpoint = request
|
||||
Endpoint = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,14 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.Profile.Commands;
|
||||
|
||||
public record UpdateProfileProcedure : IUpdateProcedure
|
||||
public record UpdateProfileProcedure : IUpdateProcedure<UpdateProfileDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
public byte? TypeId { get; set; }
|
||||
public string? Mandantor { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public byte? LogLevelId { get; set; }
|
||||
public short? LanguageId { get; set; }
|
||||
public DateTime? FirstRun { get; set; }
|
||||
public DateTime? LastRun { get; set; }
|
||||
public string? LastResult { get; set; }
|
||||
|
||||
public UpdateProfileDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<UpdateProfileProcedure, int>
|
||||
@@ -26,7 +19,7 @@ public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<Upd
|
||||
{
|
||||
Entity = "PROFILE",
|
||||
Id = request.Id,
|
||||
Profile = request
|
||||
Profile = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.Results.Commands;
|
||||
|
||||
public record UpdateResultProcedure : IUpdateProcedure
|
||||
public record UpdateResultProcedure : IUpdateProcedure<UpdateResultDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long? ActionId { get; set; }
|
||||
public short? StatusId { get; set; }
|
||||
public string? Header { get; set; }
|
||||
public string? Body { get; set; }
|
||||
|
||||
public UpdateResultDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateResultProcedureHandler(ISender sender) : IRequestHandler<UpdateResultProcedure, int>
|
||||
@@ -20,7 +19,7 @@ public class UpdateResultProcedureHandler(ISender sender) : IRequestHandler<Upda
|
||||
{
|
||||
Entity = "RESULT",
|
||||
Id = request.Id,
|
||||
Result = request
|
||||
Result = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user