From f5505190e9065edcb4873e37eb37c5ee3d890fbf Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 9 Jun 2026 23:20:53 +0200 Subject: [PATCH] Add SignatureDto and mapping for signature handling Added a new `SignatureDto` record to represent captured signatures with metadata, including properties like `ElementId`, `DataUrl`, `FullName`, `Position`, and `Place`. Updated `SigningCommand` to include a `Signatures` property for handling multiple signatures, deprecating `PsPdfKitAnnotation`. Introduced a `MappingProfile` class to map `SignatureDto` to `DocReceiverElement` using AutoMapper. Added necessary `using` directives to support the new mapping configuration. --- .../Commands/SigningCommand.cs | 69 +++++++++++++++++++ .../DocReceiverElements/MappingProfile.cs | 19 +++++ 2 files changed, 88 insertions(+) create mode 100644 EnvelopeGenerator.Application/DocReceiverElements/MappingProfile.cs diff --git a/EnvelopeGenerator.Application/DocReceiverElements/Commands/SigningCommand.cs b/EnvelopeGenerator.Application/DocReceiverElements/Commands/SigningCommand.cs index 5c308650..6d1e56fd 100644 --- a/EnvelopeGenerator.Application/DocReceiverElements/Commands/SigningCommand.cs +++ b/EnvelopeGenerator.Application/DocReceiverElements/Commands/SigningCommand.cs @@ -5,6 +5,70 @@ 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. /// @@ -31,6 +95,11 @@ public record SigningCommand : EnvelopeReceiverQueryBase, IRequest /// [Obsolete("This notification is deprecated. Use Signature.Commands.SignCommand instead.")] public PsPdfKitAnnotation? PsPdfKitAnnotation { get; init; } + + /// + /// + /// + public IEnumerable? Signatures { get; init; } } /// diff --git a/EnvelopeGenerator.Application/DocReceiverElements/MappingProfile.cs b/EnvelopeGenerator.Application/DocReceiverElements/MappingProfile.cs new file mode 100644 index 00000000..84f5c83b --- /dev/null +++ b/EnvelopeGenerator.Application/DocReceiverElements/MappingProfile.cs @@ -0,0 +1,19 @@ +using AutoMapper; +using EnvelopeGenerator.Application.DocReceiverElements.Commands; +using EnvelopeGenerator.Domain.Entities; + +namespace EnvelopeGenerator.Application.DocReceiverElements; + +/// +/// +/// +public class MappingProfile : Profile +{ + /// + /// + /// + public MappingProfile() + { + CreateMap(); + } +} \ No newline at end of file