47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
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);
|
|
|
|
}
|
|
} |