feat(notification): implement handler to remove document result on signature removal
This commit is contained in:
parent
7e8fc25ec9
commit
b798181f91
@ -0,0 +1,47 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Handlers;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class RemoveDocResult : INotificationHandler<RemoveSignatureNotification>
|
||||
{
|
||||
private readonly IRepository<Envelope> _repo;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
public RemoveDocResult(IRepository<Envelope> repository)
|
||||
{
|
||||
_repo = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="notification"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user