From 2355a566e4f47cec583e0e82c8db02d5a0719cb8 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Tue, 26 Aug 2025 16:49:22 +0200 Subject: [PATCH] refactor(EnvelopeReceiverQueryBase): simplify EnvelopeReceiverQueryBase.Key handling - Introduced private backing field `_key` for Key property - Removed dynamic recomputation from Envelope and Receiver - Ensured Key is only set once during initialization - Improved null handling and exception safety --- .../Model/EnvelopeReceiverQueryBase.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/EnvelopeGenerator.Application/Model/EnvelopeReceiverQueryBase.cs b/EnvelopeGenerator.Application/Model/EnvelopeReceiverQueryBase.cs index 8df8d522..3995263f 100644 --- a/EnvelopeGenerator.Application/Model/EnvelopeReceiverQueryBase.cs +++ b/EnvelopeGenerator.Application/Model/EnvelopeReceiverQueryBase.cs @@ -17,24 +17,26 @@ public record EnvelopeReceiverQueryBase where TEnvelopeQuery : EnvelopeQueryBase, new() where TReceiverQuery : ReceiverQueryBase, new() { + private string? _key; + /// /// /// public virtual string? Key { - get => Envelope?.Uuid is string uuid && Receiver?.Signature is string signature - ? (uuid, signature).EncodeEnvelopeReceiverId() - : null; + get => _key; init { if (value is null) + { + _key = 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 @@ -43,6 +45,7 @@ public record EnvelopeReceiverQueryBase { Signature = ReceiverSignature }; + _key = value; } }