Introduced a new `AddReceiver` method in the `Extension` class to facilitate adding a receiver to an envelope. This method includes parameters for `envelope_uuid`, `emailAdress`, `salutation`, and an optional `phone`, along with XML documentation for clarity. Removed the `EnvelopeReceiverCreateReadSQL` class and added the `EnvelopeReceiverAddReadSQL` class, which defines the SQL command for adding a receiver. The new class also includes XML documentation comments for better understanding.
54 lines
2.1 KiB
C#
54 lines
2.1 KiB
C#
using Dapper;
|
|
using EnvelopeGenerator.Application.SQL;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
|
|
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static class Extension
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="executor"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="title"></param>
|
|
/// <param name="message"></param>
|
|
/// <param name="tfaEnabled"></param>
|
|
/// <param name="cancellation"></param>
|
|
/// <returns></returns>
|
|
public static async Task<Envelope?> 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);
|
|
var envelopes = await executor.Execute<Envelope, EnvelopeCreateReadSQL>(parameters, cancellation);
|
|
return envelopes.FirstOrDefault();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="executor"></param>
|
|
/// <param name="envelope_uuid"></param>
|
|
/// <param name="emailAdress"></param>
|
|
/// <param name="salutation"></param>
|
|
/// <param name="phone"></param>
|
|
/// <param name="cancellation"></param>
|
|
/// <returns></returns>
|
|
public static async Task<EnvelopeReceiver?> AddReceiver(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<EnvelopeReceiver, EnvelopeReceiverAddReadSQL>(parameters, cancellation);
|
|
return envelopeReceivers.FirstOrDefault();
|
|
}
|
|
} |