change LoadEnvelope method

This commit is contained in:
2025-08-22 20:05:53 +02:00
parent 1577440b77
commit 30e2ac602d
4 changed files with 36 additions and 19 deletions

View File

@@ -1,6 +1,7 @@
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
using EnvelopeGenerator.Application.Envelopes.Queries;
using EnvelopeGenerator.Application.Exceptions;
using EnvelopeGenerator.Application.Extensions;
using EnvelopeGenerator.Application.Receivers.Queries;
using EnvelopeGenerator.Extensions;
using MediatR;
@@ -83,3 +84,12 @@ public record ReadEnvelopeReceiverQuery : IRequest<IEnumerable<EnvelopeReceiverD
/// </summary>
public ReadReceiverQuery? Receiver { get; set; }
};
public static class Extensions
{
public static Task<EnvelopeReceiverDto?> ReadEnvelopeReceiverAsync(this IMediator mediator, string key)
{
var q = new ReadEnvelopeReceiverQuery() { Key = key };
return mediator.Send(q).Then(envRcvs => envRcvs.FirstOrDefault());
}
}