using MediatR; using EnvelopeGenerator.Application.Common.Dto; using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver; using EnvelopeGenerator.Application.Common.Query; namespace EnvelopeGenerator.Application.DocReceiverElements.Commands; /// /// Represents a captured signature with metadata created by the receiver in the signature popup. /// This model holds the signature image (as base64 data URL) along with signer information /// used for rendering applied signatures on the PDF canvas. /// /// /// Used in: EnvelopeViewer.razor signature popup workflow ///
/// Creation: User draws/types/uploads signature and fills required fields ///
public sealed record SignatureDto { /// /// TBDD_DOCUMENT_RECEIVER_ELEMENT.ID - identifies the specific signature field on the PDF page. /// public required int ElementId { get; init; } /// /// Base64-encoded data URL of the signature image. ///
/// Format: data:image/png;base64,iVBORw0KG... ///
/// Source: Canvas.toDataURL() from signature pad (draw/text/image tabs) ///
/// Usage: Set as img.src in applied signature overlay ///
public required string DataUrl { get; init; } /// /// Full name of the signer (first and last name). ///
/// Required: Yes (validated in popup) ///
/// Example: "Max Mustermann" ///
public required string FullName { get; init; } private readonly string? _position = null; /// /// Job title or position of the signer. ///
/// Required: No (optional field) ///
/// Example: "Geschäftsführer" or empty string ///
public string? Position { get => _position; init => _position = string.IsNullOrWhiteSpace(value) ? value : null; } /// /// Location/place where the signature was created. ///
/// Required: Yes (validated in popup) ///
/// Display: Shown with current date in German format (dd.MM.yyyy) ///
/// Example: "Berlin" ? rendered as "Berlin, 26.01.2025" ///
public required string Place { get; init; } } /// /// Command to sign a document by a receiver. /// public record SigningCommand : EnvelopeReceiverQueryBase, IRequest { private EnvelopeReceiverDto? _envelopeReceiver; internal void SetEnvelopeReceiver(EnvelopeReceiverDto envelopeReceiver) { _envelopeReceiver = envelopeReceiver; } /// /// The envelope receiver information. /// public EnvelopeReceiverDto EnvelopeReceiver { get => _envelopeReceiver!; init => _envelopeReceiver = value; } /// /// The PSPDFKit annotation data. /// [Obsolete("This notification is deprecated. Use Signature.Commands.SignCommand instead.")] public PsPdfKitAnnotation? PsPdfKitAnnotation { get; init; } /// /// /// public IEnumerable? Signatures { get; init; } } /// /// Handles the sign command. All work is done by pipeline behaviors. /// This handler is intentionally empty - behaviors handle all the processing. /// public class SignCommandHandler : IRequestHandler { /// /// Executes the signing command. Pipeline behaviors handle all processing. /// /// /// /// public Task Handle(SigningCommand request, CancellationToken cancellationToken = default) { return Task.CompletedTask; } }