From 1d31f2aff96ec54610af6a4906aabe61b027f5a3 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 12 Jan 2026 16:47:57 +0100 Subject: [PATCH] Refactor InsertObjectProcedure to use nested records Reorganized InsertObjectProcedure by grouping related properties into nested record types (Action, Endpoint, EndpointAuth, Profile, Result, EndpointParams) for better encapsulation and maintainability. Updated handler logic to use new structure and set AddedWhen to DateTime.UtcNow. Improved error logging and added System.Text.Json usage. --- .../Procedures/InsertObjectProcedure.cs | 273 +++++++++--------- 1 file changed, 133 insertions(+), 140 deletions(-) diff --git a/src/ReC.Application/Common/Procedures/InsertObjectProcedure.cs b/src/ReC.Application/Common/Procedures/InsertObjectProcedure.cs index 1ab6e6c..79800ca 100644 --- a/src/ReC.Application/Common/Procedures/InsertObjectProcedure.cs +++ b/src/ReC.Application/Common/Procedures/InsertObjectProcedure.cs @@ -8,91 +8,84 @@ namespace ReC.Application.Common.Procedures; public record InsertObjectProcedure : IRequest { - #region Common - - /// - /// Target entity: ACTION, ENDPOINT, ENDPOINT_AUTH, ENDPOINT_PARAMS, PROFILE, RESULT - /// public string Entity { get; set; } = "ACTION"; public string? AddedWho { get; set; } - public DateTime? AddedWhen { get; set; } - - #endregion - - #region ACTION - - public long? ActionProfileId { get; set; } - public bool? ActionActive { get; set; } - public byte? ActionSequence { get; set; } - public long? ActionEndpointId { get; set; } - public long? ActionEndpointAuthId { get; set; } - public short? ActionEndpointParamsId { get; set; } - public short? ActionSqlConnectionId { get; set; } - public byte? ActionTypeId { get; set; } - public string? ActionPreSql { get; set; } - public string? ActionHeaderSql { get; set; } - public string? ActionBodySql { get; set; } - public string? ActionPostSql { get; set; } - public byte? ActionErrorActionId { get; set; } - - #endregion - - #region ENDPOINT - - public bool? EndpointActive { get; set; } - public string? EndpointDescription { get; set; } - public string? EndpointUri { get; set; } - - #endregion - - #region ENDPOINT_AUTH - - public bool? EndpointAuthActive { get; set; } - public string? EndpointAuthDescription { get; set; } - public byte? EndpointAuthTypeId { get; set; } - public string? EndpointAuthApiKey { get; set; } - public string? EndpointAuthApiValue { get; set; } - public bool? EndpointAuthApiKeyAddToId { get; set; } - public string? EndpointAuthToken { get; set; } - public string? EndpointAuthUsername { get; set; } - public string? EndpointAuthPassword { get; set; } - public string? EndpointAuthDomain { get; set; } - public string? EndpointAuthWorkstation { get; set; } - - #endregion - - #region PROFILE - - public bool? ProfileActive { get; set; } - public byte? ProfileTypeId { get; set; } - public string? ProfileMandantor { get; set; } - public string? ProfileName { get; set; } - public string? ProfileDescription { get; set; } - public byte? ProfileLogLevelId { get; set; } - public short? ProfileLanguageId { get; set; } - #endregion + public ActionInfo Action { get; init; } = new(); + public EndpointInfo Endpoint { get; init; } = new(); + public EndpointAuthInfo EndpointAuth { get; init; } = new(); + public ProfileInfo Profile { get; init; } = new(); + public ResultInfo Result { get; init; } = new(); + public EndpointParamsInfo EndpointParams { get; init; } = new(); - #region RESULT + public record ActionInfo + { + 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 long? ResultActionId { get; set; } - public short? ResultStatusId { get; set; } - public string? ResultHeader { get; set; } - public string? ResultBody { get; set; } + public record EndpointInfo + { + public bool? Active { get; set; } + public string? Description { get; set; } + public string? Uri { get; set; } + } - #endregion + public record EndpointAuthInfo + { + 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; } + } - #region ENDPOINT_PARAMS + public record ProfileInfo + { + 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 bool? EndpointParamsActive { get; set; } - public string? EndpointParamsDescription { get; set; } - public short? EndpointParamsGroupId { get; set; } - public byte? EndpointParamsSequence { get; set; } - public string? EndpointParamsKey { get; set; } - public string? EndpointParamsValue { get; set; } + public record ResultInfo + { + public long? ActionId { get; set; } + public short? StatusId { get; set; } + public string? Header { get; set; } + public string? Body { get; set; } + } - #endregion + public record EndpointParamsInfo + { + 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 class InsertObjectProcedureHandler(IRepository repo) : IRequestHandler @@ -104,57 +97,57 @@ public class InsertObjectProcedureHandler(IRepository repo) : IRequestHandler