feat(EnvelopeReceiverQuery): create query with Key, Envelope and Receiver properties
This commit is contained in:
58
EnvelopeGenerator.Application/Model/EnvelopeReceiverQuery.cs
Normal file
58
EnvelopeGenerator.Application/Model/EnvelopeReceiverQuery.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Model;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record EnvelopeReceiverQuery : EnvelopeReceiverQuery<EnvelopeQuery, ReceiverQuery>;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="TEnvelopeQuery"></typeparam>
|
||||
/// <typeparam name="TReceiverQuery"></typeparam>
|
||||
public record EnvelopeReceiverQuery<TEnvelopeQuery, TReceiverQuery>
|
||||
where TEnvelopeQuery : EnvelopeQuery, new()
|
||||
where TReceiverQuery : ReceiverQuery, new()
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual TEnvelopeQuery? Envelope { get; init; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual TReceiverQuery? Receiver { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user