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>
|
||||
/// DTO zum Erstellen eines Dokuments.
|
||||
/// </summary>
|
||||
/// <param name="DataAsByte">
|
||||
/// Die Dokumentdaten im Byte-Array-Format. Wird verwendet, wenn das Dokument als Roh-Binärdaten bereitgestellt wird.
|
||||
/// </param>
|
||||
public record DocumentCreateCommand(byte[]? DataAsByte = null)
|
||||
public record DocumentCreateCommand()
|
||||
{
|
||||
/// <summary>
|
||||
/// Die Dokumentdaten im Base64-String-Format. Wird verwendet, wenn das Dokument als Base64-codierter String bereitgestellt wird.
|
||||
/// </summary>
|
||||
public string? DataAsBase64 { get; set; }
|
||||
[Required]
|
||||
public required string DataAsBase64 { get; init; }
|
||||
};
|
||||
#endregion
|
||||
@ -13,15 +13,14 @@ public class EnvelopeReceiverAddReadSQL : ISQL<Envelope>
|
||||
///
|
||||
/// </summary>
|
||||
public string Raw => @"
|
||||
USE [DD_ECM]
|
||||
DECLARE @OUT_RECEIVER_ID int
|
||||
|
||||
EXEC [dbo].[PRSIG_API_CREATE_RECEIVER]
|
||||
@ENV_UID = @ENV_UID,
|
||||
@EMAIL_ADRESS = @EMAIL_ADRESS,
|
||||
@SALUTATION = @SALUTATION,
|
||||
@PHONE = @PHONE,
|
||||
@OUT_RECEIVER_ID = @OUT_RECEIVER_ID OUTPUT
|
||||
@ENV_UID,
|
||||
@EMAIL_ADRESS,
|
||||
@SALUTATION,
|
||||
@PHONE,
|
||||
@OUT_RECEIVER_ID OUTPUT
|
||||
|
||||
SELECT TOP(1) *
|
||||
FROM TBSIG_ENVELOPE_RECEIVER
|
||||
|
||||
@ -221,16 +221,6 @@ public class EnvelopeReceiverController : ControllerBase
|
||||
#endregion
|
||||
|
||||
#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);
|
||||
|
||||
if(document is null)
|
||||
@ -279,8 +269,6 @@ public class EnvelopeReceiverController : ControllerBase
|
||||
#endregion
|
||||
|
||||
#region Create history
|
||||
string connectionString = "Server=YOUR_SERVER;Database=YOUR_DATABASE;Trusted_Connection=True;";
|
||||
|
||||
string sql_hist = @"
|
||||
USE [DD_ECM]
|
||||
|
||||
@ -294,7 +282,7 @@ public class EnvelopeReceiverController : ControllerBase
|
||||
|
||||
SELECT @OUT_SUCCESS as [@OUT_SUCCESS];";
|
||||
|
||||
using (SqlConnection conn = new(connectionString))
|
||||
using (SqlConnection conn = new(_cnnStr))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user