diff --git a/EnvelopeGenerator.Application/Contracts/SQLExecutor/Extension.cs b/EnvelopeGenerator.Application/Contracts/SQLExecutor/Extension.cs index a765a090..e0a49e98 100644 --- a/EnvelopeGenerator.Application/Contracts/SQLExecutor/Extension.cs +++ b/EnvelopeGenerator.Application/Contracts/SQLExecutor/Extension.cs @@ -55,4 +55,26 @@ public static class Extension return await executor.CreateEnvelopeAsync(parameters, cancellation: cancellation); } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static async Task AddEnvelopeReceiver(this ISQLExecutor executor, string envelope_uuid, string emailAdress, string salutation, string? phone = null, CancellationToken cancellation = default) + { + var parameters = new DynamicParameters(); + parameters.Add("@ENV_UID", envelope_uuid); + parameters.Add("@EMAIL_ADRESS", emailAdress); + parameters.Add("@SALUTATION", salutation); + parameters.Add("@PHONE", phone); + + var envelopeReceivers = await executor.Execute(parameters, cancellation); + return envelopeReceivers.FirstOrDefault(); + } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/SQL/EnvelopeReceiverAddReadSQL.cs b/EnvelopeGenerator.Application/SQL/EnvelopeReceiverAddReadSQL.cs new file mode 100644 index 00000000..e4fe1881 --- /dev/null +++ b/EnvelopeGenerator.Application/SQL/EnvelopeReceiverAddReadSQL.cs @@ -0,0 +1,33 @@ +using EnvelopeGenerator.Application.Contracts.SQLExecutor; +using EnvelopeGenerator.Domain.Entities; + +namespace EnvelopeGenerator.Application.SQL; + +/// +/// +/// +public class EnvelopeReceiverAddReadSQL : ISQL +{ + /// + /// + /// + public string Raw => @" + USE [DD_ECM] + GO + + DECLARE @OUT_RECEIVER_ID int + + DECLARE @ENV_UID varchar(36) = @ENV_UID + + EXEC [dbo].[PRSIG_API_CREATE_RECEIVER] + @ENV_UID = @ENV_UID, + @EMAIL_ADRESS = @EMAIL_ADRESS , + @SALUTATION = @SALUTATION, + @PHONE = @PHONE, + @OUT_RECEIVER_ID = @OUT_RECEIVER_ID OUTPUT + + SELECT TOP(1) * + FROM TBSIG_ENVELOPE_RECEIVER + WHERE [GUID] = @OUT_RECEIVER_ID; + "; +}