Refactor envelope creation SQL logic

Removed `CreateEnvelopeSQL` and introduced `EnvelopeCreateReadSQL` to handle envelope creation logic. Updated the `Extension` class methods and modified `CreateEnvelopeAsync` in `EnvelopeExecutor` to utilize the new SQL class.
This commit is contained in:
Developer 02 2025-05-05 16:30:39 +02:00
parent b93ba6be17
commit 3955a3232d
2 changed files with 3 additions and 3 deletions

View File

@ -7,7 +7,7 @@ namespace EnvelopeGenerator.Application.SQL;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public class CreateEnvelopeSQL : ISQL<Envelope> public class EnvelopeCreateReadSQL : ISQL<Envelope>
{ {
/// <summary> /// <summary>
/// ///
@ -60,7 +60,7 @@ public static class Extension
{ {
var parameters = CreateParmas(userId, title, message, tfaEnabled); var parameters = CreateParmas(userId, title, message, tfaEnabled);
var envelopes = await executor.Execute<TEntity, CreateEnvelopeSQL>(parameters, cancellation); var envelopes = await executor.Execute<TEntity, EnvelopeCreateReadSQL>(parameters, cancellation);
return envelopes.FirstOrDefault(); return envelopes.FirstOrDefault();
} }

View File

@ -23,7 +23,7 @@ public class EnvelopeExecutor : SQLExecutor, IEnvelopeExecutor
public async Task<Envelope?> CreateEnvelopeAsync(DynamicParameters parameters, bool addUser = true, CancellationToken cancellation = default) public async Task<Envelope?> CreateEnvelopeAsync(DynamicParameters parameters, bool addUser = true, CancellationToken cancellation = default)
{ {
using var connection = new SqlConnection(Params.ConnectionString); using var connection = new SqlConnection(Params.ConnectionString);
var sql = Provider.GetRequiredService<CreateEnvelopeSQL>(); var sql = Provider.GetRequiredService<EnvelopeCreateReadSQL>();
await connection.OpenAsync(cancellation); await connection.OpenAsync(cancellation);
var envelopes = await connection.QueryAsync<Envelope>(sql.Raw, parameters); var envelopes = await connection.QueryAsync<Envelope>(sql.Raw, parameters);
var envelope = envelopes.FirstOrDefault(); var envelope = envelopes.FirstOrDefault();