refactor(RemoveSignatureNotification): Alle Filter von Handlern an die Bedingung binden, dass sie nicht null sind.

This commit is contained in:
tekh 2025-10-22 10:38:08 +02:00
parent 2004c7ced2
commit 1edcfed318
3 changed files with 46 additions and 12 deletions

View File

@ -30,10 +30,21 @@ public class RemoveAnnotationHandler : INotificationHandler<RemoveSignatureNotif
{
return _repo.DeleteAsync(annots =>
{
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);

View File

@ -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<RemoveSignatureNotifi
{
return _repo.DeleteAsync(statuses =>
{
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);

View File

@ -31,12 +31,23 @@ public class RemoveHistoryHandler : INotificationHandler<RemoveSignatureNotifica
{
return _repo.DeleteAsync(hists =>
{
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);