using DigitalData.Core.Exceptions; using EnvelopeGenerator.Extensions; namespace EnvelopeGenerator.Application.Model; /// /// /// public record EnvelopeReceiverQueryBase : EnvelopeReceiverQueryBase; /// /// /// /// /// public record EnvelopeReceiverQueryBase where TEnvelopeQuery : EnvelopeQueryBase, new() where TReceiverQuery : ReceiverQueryBase, 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; } = new(); /// /// /// public virtual TReceiverQuery Receiver { get; init; } = new(); }