refactor(ModifyDocStatusCommandBase): add EnvelopeId and ReceiverId properties
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user