refactor(ModifyDocStatusCommandBase): add EnvelopeId and ReceiverId properties

This commit is contained in:
2025-09-09 23:15:19 +02:00
parent 83ff3da795
commit 6b89b9bbf2
9 changed files with 101 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Common.Query;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Domain.Interfaces;
namespace EnvelopeGenerator.Application.Common.Extensions;
@@ -34,6 +35,28 @@ public static class QueryExtensions
return root;
}
/// <summary>
///
/// </summary>
/// <param name="root"></param>
/// <param name="query"></param>
/// <param name="notnull"></param>
/// <returns></returns>
/// <exception cref="BadRequestException"></exception>
public static IQueryable<Envelope> Where(this IQueryable<Envelope> root, EnvelopeQueryBase query, bool notnull = true)
{
if (query.Id is not null)
root = root.Where(e => e.Id == query.Id);
else if (query.Uuid is not null)
root = root.Where(e => e.Uuid == query.Uuid);
else if (notnull)
throw new BadRequestException(
"Either Envelope Id or Envelope Uuid must be provided in the query."
);
return root;
}
/// <summary>
///
/// </summary>
@@ -60,6 +83,30 @@ public static class QueryExtensions
return root;
}
/// <summary>
///
/// </summary>
/// <param name="root"></param>
/// <param name="query"></param>
/// <param name="notnull"></param>
/// <returns></returns>
/// <exception cref="BadRequestException"></exception>
public static IQueryable<Receiver> Where(this IQueryable<Receiver> root, ReceiverQueryBase query, bool notnull = true)
{
if (query.Id is not null)
root = root.Where(e => e.Id == query.Id);
else if (query.EmailAddress is not null)
root = root.Where(e => e.EmailAddress == query.EmailAddress);
else if (query.Signature is not null)
root = root.Where(e => e.Signature == query.Signature);
else if (notnull)
throw new BadRequestException(
"Receiver must have at least one identifier (Id, EmailAddress, or Signature)."
);
return root;
}
/// <summary>
///
/// </summary>