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 MediatR;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||||
|
|
||||||
namespace ReC.Application.EndpointAuth.Commands;
|
namespace ReC.Application.EndpointAuth.Commands;
|
||||||
|
|
||||||
public record UpdateEndpointAuthProcedure : IUpdateProcedure
|
public record UpdateEndpointAuthProcedure : IUpdateProcedure<UpdateEndpointAuthDto>
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public bool? Active { get; set; }
|
|
||||||
public string? Description { get; set; }
|
public UpdateEndpointAuthDto Data { get; set; } = null!;
|
||||||
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 class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointAuthProcedure, int>
|
public class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointAuthProcedure, int>
|
||||||
@@ -27,7 +19,7 @@ public class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandle
|
|||||||
{
|
{
|
||||||
Entity = "ENDPOINT_AUTH",
|
Entity = "ENDPOINT_AUTH",
|
||||||
Id = request.Id,
|
Id = request.Id,
|
||||||
EndpointAuth = request
|
EndpointAuth = request.Data
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,14 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||||
|
|
||||||
namespace ReC.Application.EndpointParams.Commands;
|
namespace ReC.Application.EndpointParams.Commands;
|
||||||
|
|
||||||
public record UpdateEndpointParamsProcedure : IUpdateProcedure
|
public record UpdateEndpointParamsProcedure : IUpdateProcedure<UpdateEndpointParamsDto>
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public bool? Active { get; set; }
|
|
||||||
public string? Description { get; set; }
|
public UpdateEndpointParamsDto Data { get; set; } = null!;
|
||||||
public short? GroupId { get; set; }
|
|
||||||
public byte? Sequence { get; set; }
|
|
||||||
public string? Key { get; set; }
|
|
||||||
public string? Value { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointParamsProcedure, int>
|
public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointParamsProcedure, int>
|
||||||
@@ -22,7 +19,7 @@ public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHand
|
|||||||
{
|
{
|
||||||
Entity = "ENDPOINT_PARAMS",
|
Entity = "ENDPOINT_PARAMS",
|
||||||
Id = request.Id,
|
Id = request.Id,
|
||||||
EndpointParams = request
|
EndpointParams = request.Data
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||||
|
|
||||||
namespace ReC.Application.Endpoints.Commands;
|
namespace ReC.Application.Endpoints.Commands;
|
||||||
|
|
||||||
public record UpdateEndpointProcedure : IUpdateProcedure
|
public record UpdateEndpointProcedure : IUpdateProcedure<UpdateEndpointDto>
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public bool? Active { get; set; }
|
|
||||||
public string? Description { get; set; }
|
public UpdateEndpointDto Data { get; set; } = null!;
|
||||||
public string? Uri { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointProcedure, int>
|
public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointProcedure, int>
|
||||||
@@ -19,7 +19,7 @@ public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<Up
|
|||||||
{
|
{
|
||||||
Entity = "ENDPOINT",
|
Entity = "ENDPOINT",
|
||||||
Id = request.Id,
|
Id = request.Id,
|
||||||
Endpoint = request
|
Endpoint = request.Data
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,14 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||||
|
|
||||||
namespace ReC.Application.Profile.Commands;
|
namespace ReC.Application.Profile.Commands;
|
||||||
|
|
||||||
public record UpdateProfileProcedure : IUpdateProcedure
|
public record UpdateProfileProcedure : IUpdateProcedure<UpdateProfileDto>
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public bool? Active { get; set; }
|
|
||||||
public byte? TypeId { get; set; }
|
public UpdateProfileDto Data { get; set; } = null!;
|
||||||
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 class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<UpdateProfileProcedure, int>
|
public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<UpdateProfileProcedure, int>
|
||||||
@@ -26,7 +19,7 @@ public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<Upd
|
|||||||
{
|
{
|
||||||
Entity = "PROFILE",
|
Entity = "PROFILE",
|
||||||
Id = request.Id,
|
Id = request.Id,
|
||||||
Profile = request
|
Profile = request.Data
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,14 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||||
|
|
||||||
namespace ReC.Application.RecActions.Commands;
|
namespace ReC.Application.RecActions.Commands;
|
||||||
|
|
||||||
public record UpdateActionProcedure : IUpdateProcedure
|
public record UpdateActionProcedure : IUpdateProcedure<UpdateActionDto>
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public long? ProfileId { get; set; }
|
|
||||||
public bool? Active { get; set; }
|
public UpdateActionDto Data { get; set; } = null!;
|
||||||
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 class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<UpdateActionProcedure, int>
|
public class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<UpdateActionProcedure, int>
|
||||||
@@ -29,7 +19,7 @@ public class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<Upda
|
|||||||
{
|
{
|
||||||
Entity = "ACTION",
|
Entity = "ACTION",
|
||||||
Id = request.Id,
|
Id = request.Id,
|
||||||
Action = request
|
Action = request.Data
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||||
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||||
|
|
||||||
namespace ReC.Application.Results.Commands;
|
namespace ReC.Application.Results.Commands;
|
||||||
|
|
||||||
public record UpdateResultProcedure : IUpdateProcedure
|
public record UpdateResultProcedure : IUpdateProcedure<UpdateResultDto>
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public long? ActionId { get; set; }
|
|
||||||
public short? StatusId { get; set; }
|
public UpdateResultDto Data { get; set; } = null!;
|
||||||
public string? Header { get; set; }
|
|
||||||
public string? Body { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UpdateResultProcedureHandler(ISender sender) : IRequestHandler<UpdateResultProcedure, int>
|
public class UpdateResultProcedureHandler(ISender sender) : IRequestHandler<UpdateResultProcedure, int>
|
||||||
@@ -20,7 +19,7 @@ public class UpdateResultProcedureHandler(ISender sender) : IRequestHandler<Upda
|
|||||||
{
|
{
|
||||||
Entity = "RESULT",
|
Entity = "RESULT",
|
||||||
Id = request.Id,
|
Id = request.Id,
|
||||||
Result = request
|
Result = request.Data
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user