EnvelopeGenerator/EnvelopeGenerator.Application/SQL/EnvelopeReceiverAddReadSQL.cs
Developer 02 06d25b6f5b Refactor SQL handling in EnvelopeGenerator application
- Added `System.Data` using directive in `EnvelopeCreateReadSQL.cs`.
- Updated SQL command strings to use parameter placeholders.
- Corrected method name from `CreateParmas` to `CreateParams` and added output parameter `@OutUid`.
- Made similar updates in `EnvelopeReceiverAddReadSQL.cs`.
- Introduced `ParamsExtensions` class with `ToSqlParam` method for converting .NET objects to SQL-safe parameter strings.
2025-05-07 13:09:59 +02:00

48 lines
1.2 KiB
C#

using Dapper;
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Application.SQL;
/// <summary>
///
/// </summary>
public class EnvelopeReceiverAddReadSQL : ISQL<Envelope>
{
/// <summary>
/// ENV_UID, EMAIL_ADRESS, SALUTATION, PHONE,
/// </summary>
public string Raw => @"
DECLARE @OUT_RECEIVER_ID int
EXEC [dbo].[PRSIG_API_CREATE_RECEIVER]
{0},
{1},
{2},
{3},
@OUT_RECEIVER_ID OUTPUT
SELECT TOP(1) *
FROM TBSIG_ENVELOPE_RECEIVER
WHERE [GUID] = @OUT_RECEIVER_ID;
";
/// <summary>
///
/// </summary>
/// <param name="envelope_uuid"></param>
/// <param name="emailAddress"></param>
/// <param name="salutation"></param>
/// <param name="phone"></param>
/// <returns></returns>
public static DynamicParameters CreateParameters(string envelope_uuid, string emailAddress, string? salutation = null, 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;
}
}