From 561b844e59ac0cb7eeb1b4ed74a295e1bb3edb5d Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 15 Jun 2026 15:07:12 +0200 Subject: [PATCH] Add filtering for active and completed envelopes Added `OnlyActive` and `OnlyCompleted` properties to the `ReadEnvelopeQuery` class to enable filtering envelopes by their active or completed status. Updated the `ReadEnvelopeQueryHandler` to apply these filters when the properties are set. Enhanced the `EnvelopeStatus` class by introducing `Active` and `Completed` status lists and adding extension methods (`IsActive` and `IsCompleted`) to determine status categories. Included necessary `using` directives for `System` and `System.Linq`. --- .../Envelopes/Queries/ReadEnvelopeQuery.cs | 16 ++++++++++ .../Constants/EnvelopeStatus.cs | 29 +++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs b/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs index 0719279e..8af36db6 100644 --- a/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs +++ b/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs @@ -14,6 +14,16 @@ namespace EnvelopeGenerator.Application.Envelopes.Queries; /// public record ReadEnvelopeQuery : EnvelopeQueryBase, IRequest> { + /// + /// + /// + public bool OnlyActive { get; init; } = false; + + /// + /// + /// + public bool OnlyCompleted { get; init; } = false; + /// /// Abfrage des Include des Umschlags /// @@ -132,6 +142,12 @@ public class ReadEnvelopeQueryHandler : IRequestHandler !status.Ignore.Contains(e.Status)); } + if(request is { OnlyActive: true }) + query = query.Where(e => Status.Active.Contains(e.Status)); + + if (request is { OnlyCompleted: true }) + query = query.Where(e => Status.Completed.Contains(e.Status)); + var envelopes = await query .Include(e => e.EnvelopeReceivers).ThenInclude(er => er.Receiver) .ToListAsync(cancel); diff --git a/EnvelopeGenerator.Domain/Constants/EnvelopeStatus.cs b/EnvelopeGenerator.Domain/Constants/EnvelopeStatus.cs index 5242a5f8..f096fd09 100644 --- a/EnvelopeGenerator.Domain/Constants/EnvelopeStatus.cs +++ b/EnvelopeGenerator.Domain/Constants/EnvelopeStatus.cs @@ -1,8 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Linq; namespace EnvelopeGenerator.Domain.Constants { - // http://wiki.dd/xwiki13/bin/view/Anwendungen/Produkt-Handbuch/Sonstiges/SignFlow/Envelope%20Status/ + // http://wiki.dd/xwiki_prod/bin/view/Anwendungen/Produkt-Handbuch/Sonstiges/signFLOW/signFLOW%20-%20Enwickler-Handbuch/4.%20Anhang/4.3%20Historie%20und%20Status%20der%20Umschl%C3%A4ge/ public enum EnvelopeStatus { Invalid = 0, @@ -49,5 +51,28 @@ namespace EnvelopeGenerator.Domain.Constants EnvelopeStatus.EnvelopeCreated, EnvelopeStatus.DocumentMod_Rotation }; + + public static readonly List Active = Enum.GetValues(typeof(EnvelopeStatus)) + .Cast() + .Where(status => status.IsActive()) + .ToList(); + + public static readonly List Completed = Enum.GetValues(typeof(EnvelopeStatus)) + .Cast() + .Where(status => status.IsCompleted()) + .ToList(); + } + + public static class EnvelopeStatusExtensions + { + public static bool IsActive(this EnvelopeStatus status) + { + return status >= EnvelopeStatus.EnvelopeCreated && status < EnvelopeStatus.EnvelopePartlySigned; + } + + public static bool IsCompleted(this EnvelopeStatus status) + { + return status >= EnvelopeStatus.EnvelopeCompletelySigned && status <= EnvelopeStatus.EnvelopeWithdrawn; + } } } \ No newline at end of file