From 7f18cd64c56d785164b46c0308f0c412b9890f02 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Tue, 26 Aug 2025 16:25:37 +0200 Subject: [PATCH] feat(EnvelopeReceiverQuery): create query with Key, Envelope and Receiver properties --- .../Model/EnvelopeReceiverQuery.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 EnvelopeGenerator.Application/Model/EnvelopeReceiverQuery.cs diff --git a/EnvelopeGenerator.Application/Model/EnvelopeReceiverQuery.cs b/EnvelopeGenerator.Application/Model/EnvelopeReceiverQuery.cs new file mode 100644 index 00000000..11cc38da --- /dev/null +++ b/EnvelopeGenerator.Application/Model/EnvelopeReceiverQuery.cs @@ -0,0 +1,58 @@ +using DigitalData.Core.Exceptions; +using EnvelopeGenerator.Extensions; + +namespace EnvelopeGenerator.Application.Model; + +/// +/// +/// +public record EnvelopeReceiverQuery : EnvelopeReceiverQuery; + +/// +/// +/// +/// +/// +public record EnvelopeReceiverQuery + where TEnvelopeQuery : EnvelopeQuery, new() + where TReceiverQuery : ReceiverQuery, new() +{ + /// + /// + /// + public virtual string? Key + { + get => Envelope?.Uuid is string uuid && Receiver?.Signature is string signature + ? (uuid, signature).EncodeEnvelopeReceiverId() + : null; + init + { + if (value is null) + return; + + (string? EnvelopeUuid, string? ReceiverSignature) = value.DecodeEnvelopeReceiverId(); + if (string.IsNullOrEmpty(EnvelopeUuid) || string.IsNullOrEmpty(ReceiverSignature)) + { + throw new BadRequestException("Der EnvelopeReceiverKey muss ein gültiger Base64-kodierter String sein, der die EnvelopeUuid und die ReceiverSignature enthält."); + } + Envelope = new TEnvelopeQuery() + { + Uuid = EnvelopeUuid + }; + Receiver = new TReceiverQuery() + { + Signature = ReceiverSignature + }; + } + } + + /// + /// + /// + public virtual TEnvelopeQuery? Envelope { get; init; } + + /// + /// + /// + public virtual TReceiverQuery? Receiver { get; init; } +} \ No newline at end of file