From 1edcfed3186c588cb891b8fadcc69a2b4980f585 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 22 Oct 2025 10:38:08 +0200 Subject: [PATCH] refactor(RemoveSignatureNotification): Alle Filter von Handlern an die Bedingung binden, dass sie nicht null sind. --- .../Handlers/RemoveAnnotationHandler.cs | 17 ++++++++++++--- .../Handlers/RemoveDocStatusHandler.cs | 20 ++++++++++++++---- .../Handlers/RemoveHistoryHandler.cs | 21 ++++++++++++++----- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveAnnotationHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveAnnotationHandler.cs index 46fba50f..bb3cb868 100644 --- a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveAnnotationHandler.cs +++ b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveAnnotationHandler.cs @@ -30,10 +30,21 @@ public class RemoveAnnotationHandler : INotificationHandler { - annots = annots.Where(annot => annot.Element!.Document.Envelope!.Uuid == notification.EnvelopeUuid); + // envelope ID filter + if (notification.EnvelopeId is int envelopeId) + annots = annots.Where(annot => annot.Element!.Document.EnvelopeId == envelopeId); - if (notification.ReceiverSignature is string signature) - annots = annots.Where(annot => annot.Element!.Receiver!.Signature == signature); + // envelope UUID filter + if (notification.EnvelopeUuid is string envelopeUuid) + annots = annots.Where(annot => annot.Element!.Document.Envelope!.Uuid == envelopeUuid); + + // receiver ID + if (notification.ReceiverId is int receiverId) + annots = annots.Where(annot => annot.Element!.ReceiverId == receiverId); + + // receiver signature + if (notification.ReceiverSignature is string receiverSignature) + annots = annots.Where(annot => annot.Element!.Receiver!.Signature == receiverSignature); return annots; }, cancel); diff --git a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveDocStatusHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveDocStatusHandler.cs index 2a1798e4..54668dda 100644 --- a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveDocStatusHandler.cs +++ b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveDocStatusHandler.cs @@ -1,4 +1,5 @@ -using DigitalData.Core.Abstraction.Application.Repository; +using AngleSharp.Html; +using DigitalData.Core.Abstraction.Application.Repository; using MediatR; namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Handlers; @@ -29,10 +30,21 @@ public class RemoveDocStatusHandler : INotificationHandler { - statuses = statuses.Where(status => status.Envelope!.Uuid == notification.EnvelopeUuid); + // envelope ID filter + if (notification.EnvelopeId is int envelopeId) + statuses = statuses.Where(status => status.EnvelopeId == envelopeId); - if (notification.ReceiverSignature is string signature) - statuses = statuses.Where(status => status.Receiver!.Signature == signature); + // envelope UUID filter + if (notification.EnvelopeUuid is string envelopeUuid) + statuses = statuses.Where(status => status.Envelope!.Uuid == envelopeUuid); + + // receiver Id filter + if (notification.ReceiverId is int receiverId) + statuses = statuses.Where(status => status.ReceiverId == receiverId); + + // receiver signature filter + if (notification.ReceiverSignature is string receiverSignature) + statuses = statuses.Where(status => status.Receiver!.Signature == receiverSignature); return statuses; }, cancel); diff --git a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs index 7d482fb3..4ba5103f 100644 --- a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs +++ b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveHistoryHandler.cs @@ -31,12 +31,23 @@ public class RemoveHistoryHandler : INotificationHandler { - hists = hists - .Where(hist => hist.Envelope!.Uuid == notification.EnvelopeUuid) - .Where(hist => hist.Status == EnvelopeStatus.DocumentSigned); + hists = hists.Where(hist => hist.Status == EnvelopeStatus.DocumentSigned); - if (notification.ReceiverSignature is string signature) - hists = hists.Where(hist => hist.Receiver!.Signature == signature); + // envelope ID filter + if (notification.EnvelopeId is int envelopeId) + hists = hists.Where(hist => hist.EnvelopeId == envelopeId); + + // envelope UUID filter + if (notification.EnvelopeUuid is string envelopeUuid) + hists = hists.Where(hist => hist.Envelope!.Uuid == envelopeUuid); + + // receiver ID filter + if (notification.ReceiverId is int receiverId) + hists = hists.Where(hist => hist.Receiver!.Id == receiverId); + + // receiver signature filter + if (notification.ReceiverSignature is string receiverSignature) + hists = hists.Where(hist => hist.Receiver!.Signature == receiverSignature); return hists; }, cancel);