- 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.
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using Dapper;
|
|
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using System.Data;
|
|
|
|
namespace EnvelopeGenerator.Application.SQL;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class EnvelopeCreateReadSQL : ISQL<Envelope>
|
|
{
|
|
/// <summary>
|
|
/// USER_ID, TITLE, TFAEnabled, MESSAGE
|
|
/// </summary>
|
|
public string Raw => @"
|
|
DECLARE @OUT_UID varchar(36);
|
|
|
|
EXEC [dbo].[PRSIG_API_CREATE_ENVELOPE]
|
|
{0},
|
|
{1},
|
|
{2},
|
|
{3},
|
|
@OUT_UID OUTPUT;
|
|
|
|
SELECT TOP(1) *
|
|
FROM [dbo].[TBSIG_ENVELOPE]
|
|
WHERE [ENVELOPE_UUID] = @OUT_UID;
|
|
";
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
/// <param name="title"></param>
|
|
/// <param name="message"></param>
|
|
/// <param name="tfaEnabled"></param>
|
|
/// <returns></returns>
|
|
public static DynamicParameters CreateParams(int userId, string title = "", string message = "", bool tfaEnabled = false)
|
|
{
|
|
var parameters = new DynamicParameters();
|
|
parameters.Add("@UserId", userId);
|
|
parameters.Add("@Title", title);
|
|
parameters.Add("@TfaEnabled", tfaEnabled ? 1 : 0);
|
|
parameters.Add("@Message", message);
|
|
parameters.Add("@OutUid", dbType: DbType.String, size: 36, direction: ParameterDirection.Output);
|
|
return parameters;
|
|
}
|
|
} |