diff --git a/EnvelopeGenerator.Application/Contracts/SQLExecutor/IEnvelopeReceiverExecutor.cs b/EnvelopeGenerator.Application/Contracts/SQLExecutor/IEnvelopeReceiverExecutor.cs index 73120389..10bcbe28 100644 --- a/EnvelopeGenerator.Application/Contracts/SQLExecutor/IEnvelopeReceiverExecutor.cs +++ b/EnvelopeGenerator.Application/Contracts/SQLExecutor/IEnvelopeReceiverExecutor.cs @@ -1,8 +1,20 @@ -namespace EnvelopeGenerator.Application.Contracts.SQLExecutor; +using EnvelopeGenerator.Domain.Entities; + +namespace EnvelopeGenerator.Application.Contracts.SQLExecutor; /// /// /// public interface IEnvelopeReceiverExecutor { + /// + /// + /// + /// + /// + /// + /// + /// + /// + Task AddEnvelopeReceiverAsync(string envelope_uuid, string emailAddress, string salutation, string? phone = null, CancellationToken cancellation = default); } diff --git a/EnvelopeGenerator.Application/SQL/EnvelopeReceiverAddReadSQL.cs b/EnvelopeGenerator.Application/SQL/EnvelopeReceiverAddReadSQL.cs index e4fe1881..c94aecbc 100644 --- a/EnvelopeGenerator.Application/SQL/EnvelopeReceiverAddReadSQL.cs +++ b/EnvelopeGenerator.Application/SQL/EnvelopeReceiverAddReadSQL.cs @@ -1,4 +1,5 @@ -using EnvelopeGenerator.Application.Contracts.SQLExecutor; +using Dapper; +using EnvelopeGenerator.Application.Contracts.SQLExecutor; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.SQL; @@ -30,4 +31,22 @@ public class EnvelopeReceiverAddReadSQL : ISQL FROM TBSIG_ENVELOPE_RECEIVER WHERE [GUID] = @OUT_RECEIVER_ID; "; + + /// + /// + /// + /// + /// + /// + /// + /// + public static DynamicParameters CreateParameters(string envelope_uuid, string emailAddress, string salutation, string? phone = null) + { + var parameters = new DynamicParameters(); + parameters.Add("@ENV_UID", envelope_uuid); + parameters.Add("@EMAIL_ADRESS", emailAddress); + parameters.Add("@SALUTATION", salutation); + parameters.Add("@PHONE", phone); + return parameters; + } } diff --git a/EnvelopeGenerator.Infrastructure/Executor/EnvelopeReceiverExecutor.cs b/EnvelopeGenerator.Infrastructure/Executor/EnvelopeReceiverExecutor.cs index 7120aaa4..f62a3b96 100644 --- a/EnvelopeGenerator.Infrastructure/Executor/EnvelopeReceiverExecutor.cs +++ b/EnvelopeGenerator.Infrastructure/Executor/EnvelopeReceiverExecutor.cs @@ -19,12 +19,12 @@ public class EnvelopeReceiverExecutor: SQLExecutor, IEnvelopeReceiverExecutor _erRepository = erRepository; } - public async Task AddEnvelopeReceiverAsync(DynamicParameters parameters, bool addEnvelope = true, CancellationToken cancellation = default) + public async Task AddEnvelopeReceiverAsync(string envelope_uuid, string emailAddress, string salutation, string? phone = null, CancellationToken cancellation = default) { using var connection = new SqlConnection(Params.ConnectionString); var sql = Provider.GetRequiredService(); await connection.OpenAsync(cancellation); - var envelopeReceivers = await connection.QueryAsync(sql.Raw, parameters); + var envelopeReceivers = await connection.QueryAsync(sql.Raw, EnvelopeReceiverAddReadSQL.CreateParameters(envelope_uuid, emailAddress, salutation, phone)); var er = envelopeReceivers.FirstOrDefault(); if (er is null)