Updated the `DocumentCreateCommand` record to include a nullable `DataAsBase64` property for better encapsulation. Enhanced the `EnvelopeReceiverController` with logic to validate document data, ensuring that either `DataAsBase64` or `DataAsByte` is provided, but not both. Introduced a new static method `IsBase64String` to validate base64 string format.
49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
|
|
|
#region DTOs
|
|
/// <summary>
|
|
/// Signaturposition auf einem Dokument.
|
|
/// </summary>
|
|
/// <param name="X">X-Position</param>
|
|
/// <param name="Y">Y-Position</param>
|
|
/// <param name="Page">Seite, auf der sie sich befindet</param>
|
|
public record Signature([Required] int X, [Required] int Y, [Required] int Page);
|
|
|
|
/// <summary>
|
|
/// DTO für Empfänger, die erstellt oder abgerufen werden sollen.
|
|
/// Wenn nicht, wird sie erstellt und mit einer Signatur versehen.
|
|
/// </summary>
|
|
/// <param name="Signatures">Unterschriften auf Dokumenten.</param>
|
|
/// <param name="Salution">Der Name, mit dem der Empfänger angesprochen werden soll. Bei Null oder keinem Wert wird der zuletzt verwendete Name verwendet.</param>
|
|
/// <param name="PhoneNumber">Sollte mit Vorwahl geschrieben werden</param>
|
|
public record ReceiverGetOrCreateCommand([Required] IEnumerable<Signature> Signatures, string? Salution = null, string? PhoneNumber = null)
|
|
{
|
|
private string? _emailAddress = "h.tek@digitaldata.works";
|
|
|
|
/// <summary>
|
|
/// E-Mail-Adresse des Empfängers.
|
|
/// </summary>
|
|
public string? EmailAddress { get => _emailAddress?.ToLower(); init => _emailAddress = _emailAddress?.ToLower() ?? "h.tek@digitaldata.works"; }
|
|
};
|
|
|
|
/// <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)
|
|
{
|
|
/// <summary>
|
|
/// Die Dokumentdaten im Base64-String-Format. Wird verwendet, wenn das Dokument als Base64-codierter String bereitgestellt wird.
|
|
/// </summary>
|
|
public string? DataAsBase64 { get; set; }
|
|
};
|
|
#endregion |