refactor: update CountHistoryQueryExtensions to use IEnumerable<EnvelopeStatus> and improve status handling
This commit is contained in:
parent
b9c86ce3c6
commit
99e3e4c24d
@ -26,12 +26,12 @@ public static class CountHistoryQueryExtensions
|
|||||||
/// <param name="statuses"></param>
|
/// <param name="statuses"></param>
|
||||||
/// <param name="cancel"></param>
|
/// <param name="cancel"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<bool> AnyHistoryAsync(this ISender sender, string uuid, EnvelopeStatusQuery statuses, CancellationToken cancel = default)
|
public static async Task<bool> AnyHistoryAsync(this ISender sender, string uuid, IEnumerable<EnvelopeStatus> statuses, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
var count = await sender.Send(new CountHistoryQuery
|
var count = await sender.Send(new CountHistoryQuery
|
||||||
{
|
{
|
||||||
Envelope = new() { Uuid = uuid },
|
Envelope = new() { Uuid = uuid },
|
||||||
Statuses = statuses
|
Statuses = new() { Include = statuses }
|
||||||
}, cancel);
|
}, cancel);
|
||||||
return count > 0;
|
return count > 0;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ public class CountHistoryQueryHandler : IRequestHandler<CountHistoryQuery, int>
|
|||||||
if (status.Max is not null)
|
if (status.Max is not null)
|
||||||
query = query.Where(er => er.Envelope!.Status <= status.Max);
|
query = query.Where(er => er.Envelope!.Status <= status.Max);
|
||||||
|
|
||||||
if (status.Include?.Length > 0)
|
if (status.Include?.Count() > 0)
|
||||||
query = query.Where(er => status.Include.Contains(er.Envelope!.Status));
|
query = query.Where(er => status.Include.Contains(er.Envelope!.Status));
|
||||||
|
|
||||||
if (status.Ignore is not null)
|
if (status.Ignore is not null)
|
||||||
|
|||||||
@ -51,10 +51,10 @@ public record EnvelopeStatusQuery
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Eine Liste von Statuswerten, die einbezogen werden.
|
/// Eine Liste von Statuswerten, die einbezogen werden.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EnvelopeStatus[]? Include { get; init; }
|
public IEnumerable<EnvelopeStatus>? Include { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Eine Liste von Statuswerten, die ignoriert werden werden.
|
/// Eine Liste von Statuswerten, die ignoriert werden werden.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EnvelopeStatus[]? Ignore { get; init; }
|
public IEnumerable<EnvelopeStatus>? Ignore { get; init; }
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumer
|
|||||||
if (status.Max is not null)
|
if (status.Max is not null)
|
||||||
query = query.Where(er => er.Envelope!.Status <= status.Max);
|
query = query.Where(er => er.Envelope!.Status <= status.Max);
|
||||||
|
|
||||||
if (status.Include?.Length > 0)
|
if (status.Include?.Count() > 0)
|
||||||
query = query.Where(er => status.Include.Contains(er.Envelope!.Status));
|
query = query.Where(er => status.Include.Contains(er.Envelope!.Status));
|
||||||
|
|
||||||
if (status.Ignore is not null)
|
if (status.Ignore is not null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user