40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using EnvelopeGenerator.Application.Common.Extensions;
|
|
using EnvelopeGenerator.Application.Histories.Commands;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
using MediatR;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Handlers;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class RemoveHistoryHandler : INotificationHandler<RemoveSignatureNotification>
|
|
{
|
|
private readonly IRepository _repo;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="repository"></param>
|
|
public RemoveHistoryHandler(IRepository repository)
|
|
{
|
|
_repo = repository;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="notification"></param>
|
|
/// <param name="cancel"></param>
|
|
/// <returns></returns>
|
|
public async Task Handle(RemoveSignatureNotification notification, CancellationToken cancel)
|
|
{
|
|
await _repo.DeleteAsync<Domain.Entities.History>(hists
|
|
=> hists
|
|
.Where(hist => hist.EnvelopeId == notification.EnvelopeId)
|
|
.Where(hist => hist.Status == EnvelopeStatus.DocumentSigned)
|
|
, cancel);
|
|
}
|
|
} |