diff --git a/src/ReC.Application/Common/Procedures/InsertObjectProcedure.cs b/src/ReC.Application/Common/Procedures/InsertObjectProcedure.cs index 79800ca..3b1c58b 100644 --- a/src/ReC.Application/Common/Procedures/InsertObjectProcedure.cs +++ b/src/ReC.Application/Common/Procedures/InsertObjectProcedure.cs @@ -6,86 +6,148 @@ using System.Text.Json; namespace ReC.Application.Common.Procedures; +public interface IInsertProcedure +{ + public InsertObjectProcedure ToObjectProcedure(); +} + +public record InsertActionProcedure : IInsertProcedure +{ + 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 InsertObjectProcedure ToObjectProcedure() + { + return new InsertObjectProcedure + { + Entity = "ACTION", + Action = this + }; + } +} + +public record InsertEndpointProcedure : IInsertProcedure +{ + public bool? Active { get; set; } + public string? Description { get; set; } + public string? Uri { get; set; } + + public InsertObjectProcedure ToObjectProcedure() + { + return new InsertObjectProcedure + { + Entity = "ENDPOINT", + Endpoint = this + }; + } +} + +public record InsertEndpointAuthProcedure : IInsertProcedure +{ + 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 InsertObjectProcedure ToObjectProcedure() + { + return new InsertObjectProcedure + { + Entity = "ENDPOINT_AUTH", + EndpointAuth = this + }; + } +} + +public record InsertProfileProcedure : IInsertProcedure +{ + 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 InsertObjectProcedure ToObjectProcedure() + { + return new InsertObjectProcedure + { + Entity = "PROFILE", + Profile = this + }; + } +} + +public record InsertResultProcedure : IInsertProcedure +{ + public long? ActionId { get; set; } + public short? StatusId { get; set; } + public string? Header { get; set; } + public string? Body { get; set; } + + public InsertObjectProcedure ToObjectProcedure() + { + return new InsertObjectProcedure + { + Entity = "RESULT", + Result = this + }; + } +} + +public record InsertEndpointParamsProcedure : IInsertProcedure +{ + 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 InsertObjectProcedure ToObjectProcedure() + { + return new InsertObjectProcedure + { + Entity = "ENDPOINT_PARAMS", + EndpointParams = this + }; + } +} + public record InsertObjectProcedure : IRequest { - public string Entity { get; set; } = "ACTION"; + /// + /// Target entity: ACTION, ENDPOINT, ENDPOINT_AUTH, ENDPOINT_PARAMS, PROFILE, RESULT + /// + public string Entity { get; set; } = null!; public string? AddedWho { get; set; } - 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(); - - 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 record EndpointInfo - { - public bool? Active { get; set; } - public string? Description { get; set; } - public string? Uri { get; set; } - } - - 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; } - } - - 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 record ResultInfo - { - public long? ActionId { get; set; } - public short? StatusId { get; set; } - public string? Header { get; set; } - public string? Body { get; set; } - } - - 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 InsertActionProcedure Action { get; set; } = new(); + public InsertEndpointProcedure Endpoint { get; set; } = new(); + public InsertEndpointAuthProcedure EndpointAuth { get; set; } = new(); + public InsertProfileProcedure Profile { get; set; } = new(); + public InsertResultProcedure Result { get; set; } = new(); + public InsertEndpointParamsProcedure EndpointParams { get; set; } = new(); } public class InsertObjectProcedureHandler(IRepository repo) : IRequestHandler