diff --git a/EnvelopeGenerator.Application/Contracts/SQLExecutor/Extension.cs b/EnvelopeGenerator.Application/Contracts/SQLExecutor/Extension.cs
index a765a090..2972ce0d 100644
--- a/EnvelopeGenerator.Application/Contracts/SQLExecutor/Extension.cs
+++ b/EnvelopeGenerator.Application/Contracts/SQLExecutor/Extension.cs
@@ -9,50 +9,24 @@ namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
///
public static class Extension
{
- private static DynamicParameters CreateParmas(int userId, string title = "", string message = "", bool tfaEnabled = false)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task CreateEnvelopeAsync(this ISQLExecutor executor, int userId, string title = "", string message = "", bool tfaEnabled = false, CancellationToken cancellation = default)
{
var parameters = new DynamicParameters();
parameters.Add("@UserId", userId);
parameters.Add("@Title", title);
parameters.Add("@TfaEnabled", tfaEnabled ? 1 : 0);
parameters.Add("@Message", message);
- return parameters;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static async Task CreateEnvelopeAsync(this ISQLExecutor executor, int userId, string title = "", string message = "", bool tfaEnabled = false, CancellationToken cancellation = default)
- where TEntity : class
- {
- var parameters = CreateParmas(userId, title, message, tfaEnabled);
-
- var envelopes = await executor.Execute(parameters, cancellation);
+ var envelopes = await executor.Execute(parameters, cancellation);
return envelopes.FirstOrDefault();
}
-
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static async Task CreateEnvelopeAsync(this IEnvelopeExecutor executor, int userId, string title = "", string message = "", bool tfaEnabled = false, CancellationToken cancellation = default)
- {
- var parameters = CreateParmas(userId, title, message, tfaEnabled);
-
- return await executor.CreateEnvelopeAsync(parameters, cancellation: cancellation);
- }
}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/Contracts/SQLExecutor/IEnvelopeExecutor.cs b/EnvelopeGenerator.Application/Contracts/SQLExecutor/IEnvelopeExecutor.cs
deleted file mode 100644
index f197cadf..00000000
--- a/EnvelopeGenerator.Application/Contracts/SQLExecutor/IEnvelopeExecutor.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Dapper;
-using EnvelopeGenerator.Domain.Entities;
-
-namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
-
-///
-///
-///
-public interface IEnvelopeExecutor : ISQLExecutor
-{
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- Task CreateEnvelopeAsync(DynamicParameters parameters, bool addUser = true, CancellationToken cancellation = default);
-}
diff --git a/EnvelopeGenerator.Application/Envelopes/Commands/CreateEnvelopeCommandHandler.cs b/EnvelopeGenerator.Application/Envelopes/Commands/CreateEnvelopeCommandHandler.cs
index 5c8cb3e9..35bfe61f 100644
--- a/EnvelopeGenerator.Application/Envelopes/Commands/CreateEnvelopeCommandHandler.cs
+++ b/EnvelopeGenerator.Application/Envelopes/Commands/CreateEnvelopeCommandHandler.cs
@@ -9,18 +9,18 @@ namespace EnvelopeGenerator.Application.Envelopes.Commands;
///
public class CreateEnvelopeCommandHandler : IRequestHandler
{
- private readonly IEnvelopeExecutor _envelopeExecutor;
+ private readonly ISQLExecutor _executor;
private readonly IMapper _mapper;
///
///
///
- ///
+ ///
///
- public CreateEnvelopeCommandHandler(IEnvelopeExecutor envelopeExecutor, IMapper mapper)
+ public CreateEnvelopeCommandHandler(ISQLExecutor executor, IMapper mapper)
{
- _envelopeExecutor = envelopeExecutor;
+ _executor = executor;
_mapper = mapper;
}
@@ -34,7 +34,7 @@ public class CreateEnvelopeCommandHandler : IRequestHandler(envelope);
}
diff --git a/EnvelopeGenerator.Application/SQL/EnvelopeReceiverCreateReadSQL.cs b/EnvelopeGenerator.Application/SQL/EnvelopeReceiverCreateReadSQL.cs
new file mode 100644
index 00000000..3f9b2db8
--- /dev/null
+++ b/EnvelopeGenerator.Application/SQL/EnvelopeReceiverCreateReadSQL.cs
@@ -0,0 +1,33 @@
+using EnvelopeGenerator.Application.Contracts.SQLExecutor;
+using EnvelopeGenerator.Domain.Entities;
+
+namespace EnvelopeGenerator.Application.SQL;
+
+///
+///
+///
+public class EnvelopeReceiverCreateReadSQL : 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;
+ ";
+}
diff --git a/EnvelopeGenerator.Infrastructure/DependencyExtensions.cs b/EnvelopeGenerator.Infrastructure/DependencyExtensions.cs
index d9d3bd92..c1138538 100644
--- a/EnvelopeGenerator.Infrastructure/DependencyExtensions.cs
+++ b/EnvelopeGenerator.Infrastructure/DependencyExtensions.cs
@@ -82,8 +82,6 @@ public static class DIExtensions
SetDapperTypeMap();
SetDapperTypeMap();
- services.AddScoped();
-
if (sqlExecutorConfiguration is not null || sqlExecutorConfigureOptions is not null)
services.AddSQLExecutor(sqlExecutorConfiguration, sqlExecutorConfigureOptions);
diff --git a/EnvelopeGenerator.Infrastructure/Executor/EnvelopeExecutor.cs b/EnvelopeGenerator.Infrastructure/Executor/EnvelopeExecutor.cs
deleted file mode 100644
index dca802ba..00000000
--- a/EnvelopeGenerator.Infrastructure/Executor/EnvelopeExecutor.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using Dapper;
-using DigitalData.UserManager.Application.Contracts.Repositories;
-using DigitalData.UserManager.Infrastructure.Repositories;
-using EnvelopeGenerator.Application.Contracts.SQLExecutor;
-using EnvelopeGenerator.Application.SQL;
-using EnvelopeGenerator.Domain.Entities;
-using Microsoft.Data.SqlClient;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
-
-namespace EnvelopeGenerator.Infrastructure.Executor;
-
-public class EnvelopeExecutor : SQLExecutor, IEnvelopeExecutor
-{
- private readonly IUserRepository _userRepository;
-
- public EnvelopeExecutor(ILogger logger, IServiceProvider provider, IOptions sqlExecutorParamsOptions, IUserRepository userRepository) : base(provider, sqlExecutorParamsOptions)
- {
- _userRepository = userRepository;
- }
-
- public async Task CreateEnvelopeAsync(DynamicParameters parameters, bool addUser = true, CancellationToken cancellation = default)
- {
- using var connection = new SqlConnection(Params.ConnectionString);
- var sql = Provider.GetRequiredService();
- await connection.OpenAsync(cancellation);
- var envelopes = await connection.QueryAsync(sql.Raw, parameters);
- var envelope = envelopes.FirstOrDefault();
-
- if (envelope is null)
- return null;
-
- // Add User
- if (addUser)
- {
- var user = await _userRepository.ReadByIdAsync(envelope.UserId);
- envelope.User = user;
- }
-
- return envelope;
- }
-}
\ No newline at end of file