diff --git a/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveDocResult.cs b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveDocResult.cs new file mode 100644 index 00000000..9b8d810a --- /dev/null +++ b/EnvelopeGenerator.Application/Common/Notifications/RemoveSignature/Handlers/RemoveDocResult.cs @@ -0,0 +1,47 @@ +using DigitalData.Core.Abstraction.Application.Repository; +using EnvelopeGenerator.Domain.Entities; +using MediatR; + +namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Handlers; + +/// +/// +/// +public class RemoveDocResult : INotificationHandler +{ + private readonly IRepository _repo; + + /// + /// + /// + /// + public RemoveDocResult(IRepository repository) + { + _repo = repository; + } + + /// + /// + /// + /// + /// + /// + public Task Handle(RemoveSignatureNotification notification, CancellationToken cancel) + { + if(notification.EnvelopeId is null && notification.EnvelopeUuid is null) + return Task.CompletedTask; + + return _repo.UpdateAsync( + envelope => envelope.DocResult = null, + query => { + if (notification.EnvelopeId is int envelopeId) + query = query.Where(envelope => envelope.Id == envelopeId); + + if (notification.EnvelopeUuid is string uuid) + query = query.Where(envelope => envelope.Uuid == uuid); + + return query; + }, cancel); + + } +} \ No newline at end of file