diff --git a/EnvelopeGenerator.Application/Extensions/QueryExtensions.cs b/EnvelopeGenerator.Application/Extensions/QueryExtensions.cs
index 4235dd54..a43cec9b 100644
--- a/EnvelopeGenerator.Application/Extensions/QueryExtensions.cs
+++ b/EnvelopeGenerator.Application/Extensions/QueryExtensions.cs
@@ -1,8 +1,63 @@
-namespace EnvelopeGenerator.Application.Extensions;
+using DigitalData.Core.Exceptions;
+using EnvelopeGenerator.Application.Model;
+using EnvelopeGenerator.Domain.Interfaces;
+
+namespace EnvelopeGenerator.Application.Extensions;
///
///
///
public static class QueryExtensions
{
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IQueryable Where(this IQueryable root, IHasEnvelopeQuery query, bool notnull = true)
+ where TEntity : IHasEnvelope where TEnvelopeQuery : EnvelopeQueryBase
+ {
+ if (query.Envelope.Id is not null)
+ root = root.Where(e => e.Envelope!.Id == query.Envelope.Id);
+ else if (query.Envelope.Uuid is not null)
+ root = root.Where(e => e.Envelope!.Uuid == query.Envelope.Uuid);
+ else if (notnull)
+ throw new BadRequestException(
+ "Either Envelope Id or Envelope Uuid must be provided in the query."
+ );
+
+ return root;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IQueryable Where(this IQueryable root, IHasReceiverQuery query, bool notnull = true)
+ where TEntity : IHasReceiver where TReceiverQueryBase : ReceiverQueryBase
+ {
+ if (query.Receiver.Id is not null)
+ root = root.Where(e => e.Receiver!.Id == query.Receiver.Id);
+ else if (query.Receiver.EmailAddress is not null)
+ root = root.Where(e => e.Receiver!.EmailAddress == query.Receiver.EmailAddress);
+ else if (query.Receiver.Signature is not null)
+ root = root.Where(e => e.Receiver!.Signature == query.Receiver.Signature);
+ else if (notnull)
+ throw new BadRequestException(
+ "Receiver must have at least one identifier (Id, EmailAddress, or Signature)."
+ );
+
+ return root;
+ }
}
diff --git a/EnvelopeGenerator.Domain/Interfaces/IHasEnvelope.cs b/EnvelopeGenerator.Domain/Interfaces/IHasEnvelope.cs
index bfc38712..93eea3bd 100644
--- a/EnvelopeGenerator.Domain/Interfaces/IHasEnvelope.cs
+++ b/EnvelopeGenerator.Domain/Interfaces/IHasEnvelope.cs
@@ -5,7 +5,7 @@
{
#endif
-interface IHasEnvelope
+public interface IHasEnvelope
{
#if NET
public
diff --git a/EnvelopeGenerator.Domain/Interfaces/IHasReceiver.cs b/EnvelopeGenerator.Domain/Interfaces/IHasReceiver.cs
index d14c9ca6..0b105a3e 100644
--- a/EnvelopeGenerator.Domain/Interfaces/IHasReceiver.cs
+++ b/EnvelopeGenerator.Domain/Interfaces/IHasReceiver.cs
@@ -5,7 +5,7 @@
{
#endif
-interface IHasReceiver
+public interface IHasReceiver
{
#if NET
public