Refactor command records and simplify document handling
- Updated `ReceiverGetOrCreateCommand` to include a required `IEnumerable<Signature>`. - Modified `DocumentCreateCommand` to remove `DataAsByte` and enforce a required `DataAsBase64` property with immutability. - Cleaned up SQL command formatting in `EnvelopeReceiverAddReadSQL`. - Simplified document validation logic in `EnvelopeReceiverController` by removing redundant checks. - Changed hardcoded connection string to a variable `_cnnStr` for improved security and flexibility.
This commit is contained in:
parent
49ccd9fef2
commit
55b01cf396
@ -36,14 +36,12 @@ public record ReceiverGetOrCreateCommand([Required] IEnumerable<Signature> Signa
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTO zum Erstellen eines Dokuments.
|
/// DTO zum Erstellen eines Dokuments.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="DataAsByte">
|
public record DocumentCreateCommand()
|
||||||
/// Die Dokumentdaten im Byte-Array-Format. Wird verwendet, wenn das Dokument als Roh-Binärdaten bereitgestellt wird.
|
|
||||||
/// </param>
|
|
||||||
public record DocumentCreateCommand(byte[]? DataAsByte = null)
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Die Dokumentdaten im Base64-String-Format. Wird verwendet, wenn das Dokument als Base64-codierter String bereitgestellt wird.
|
/// Die Dokumentdaten im Base64-String-Format. Wird verwendet, wenn das Dokument als Base64-codierter String bereitgestellt wird.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? DataAsBase64 { get; set; }
|
[Required]
|
||||||
|
public required string DataAsBase64 { get; init; }
|
||||||
};
|
};
|
||||||
#endregion
|
#endregion
|
||||||
@ -13,15 +13,14 @@ public class EnvelopeReceiverAddReadSQL : ISQL<Envelope>
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Raw => @"
|
public string Raw => @"
|
||||||
USE [DD_ECM]
|
|
||||||
DECLARE @OUT_RECEIVER_ID int
|
DECLARE @OUT_RECEIVER_ID int
|
||||||
|
|
||||||
EXEC [dbo].[PRSIG_API_CREATE_RECEIVER]
|
EXEC [dbo].[PRSIG_API_CREATE_RECEIVER]
|
||||||
@ENV_UID = @ENV_UID,
|
@ENV_UID,
|
||||||
@EMAIL_ADRESS = @EMAIL_ADRESS,
|
@EMAIL_ADRESS,
|
||||||
@SALUTATION = @SALUTATION,
|
@SALUTATION,
|
||||||
@PHONE = @PHONE,
|
@PHONE,
|
||||||
@OUT_RECEIVER_ID = @OUT_RECEIVER_ID OUTPUT
|
@OUT_RECEIVER_ID OUTPUT
|
||||||
|
|
||||||
SELECT TOP(1) *
|
SELECT TOP(1) *
|
||||||
FROM TBSIG_ENVELOPE_RECEIVER
|
FROM TBSIG_ENVELOPE_RECEIVER
|
||||||
|
|||||||
@ -221,16 +221,6 @@ public class EnvelopeReceiverController : ControllerBase
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Add document
|
#region Add document
|
||||||
if(request.Document.DataAsBase64 is null)
|
|
||||||
if (request.Document.DataAsByte is null)
|
|
||||||
return BadRequest("No document data is found");
|
|
||||||
else
|
|
||||||
request.Document.DataAsBase64 = Convert.ToBase64String(request.Document.DataAsByte);
|
|
||||||
else if (request.Document.DataAsByte is not null)
|
|
||||||
return BadRequest("Document data cannot be assigned as both byte data and base64 string.");
|
|
||||||
else if (!IsBase64String(request.Document.DataAsBase64))
|
|
||||||
return BadRequest("Document data is not a base64 string");
|
|
||||||
|
|
||||||
var document = await _documentExecutor.CreateDocumentAsync(request.Document.DataAsBase64, envelope.Uuid, cancel);
|
var document = await _documentExecutor.CreateDocumentAsync(request.Document.DataAsBase64, envelope.Uuid, cancel);
|
||||||
|
|
||||||
if(document is null)
|
if(document is null)
|
||||||
@ -279,8 +269,6 @@ public class EnvelopeReceiverController : ControllerBase
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Create history
|
#region Create history
|
||||||
string connectionString = "Server=YOUR_SERVER;Database=YOUR_DATABASE;Trusted_Connection=True;";
|
|
||||||
|
|
||||||
string sql_hist = @"
|
string sql_hist = @"
|
||||||
USE [DD_ECM]
|
USE [DD_ECM]
|
||||||
|
|
||||||
@ -294,7 +282,7 @@ public class EnvelopeReceiverController : ControllerBase
|
|||||||
|
|
||||||
SELECT @OUT_SUCCESS as [@OUT_SUCCESS];";
|
SELECT @OUT_SUCCESS as [@OUT_SUCCESS];";
|
||||||
|
|
||||||
using (SqlConnection conn = new(connectionString))
|
using (SqlConnection conn = new(_cnnStr))
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user