Refactored `DocSignedNotification` to remove inheritance from `EnvelopeReceiverDto` and introduced a required `EnvelopeReceiver` property. Updated all usages across the codebase to align with the new structure, including controllers, handlers, and tests. - Improved encapsulation and reduced coupling by making dependencies explicit. - Updated `AnnotationController`, `DocStatusHandler`, `HistoryHandler`, and `SendSignedMailHandler` to use the `EnvelopeReceiver` property. - Adjusted `DocSignedNotificationTests` to reflect the new instantiation pattern. - Updated XML documentation and ensured consistent access to `EnvelopeReceiver` properties like `EnvelopeId`, `ReceiverId`, and `EmailAddress`.
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using EnvelopeGenerator.Application.Common.Extensions;
|
|
using EnvelopeGenerator.Application.Histories.Commands;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
using MediatR;
|
|
|
|
namespace EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class HistoryHandler : INotificationHandler<DocSignedNotification>
|
|
{
|
|
private readonly ISender _sender;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
public HistoryHandler(ISender sender)
|
|
{
|
|
_sender = sender;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="notification"></param>
|
|
/// <param name="cancel"></param>
|
|
/// <returns></returns>
|
|
public async Task Handle(DocSignedNotification notification, CancellationToken cancel)
|
|
{
|
|
if (notification.EnvelopeReceiver.Receiver is null)
|
|
throw new InvalidOperationException($"Receiver information is missing in the notification. DocSignedNotification:\n {notification.ToJson(Format.Json.ForDiagnostics)}");
|
|
|
|
await _sender.Send(new CreateHistoryCommand()
|
|
{
|
|
EnvelopeId = notification.EnvelopeReceiver.EnvelopeId,
|
|
UserReference = notification.EnvelopeReceiver.Receiver.EmailAddress,
|
|
Status = EnvelopeStatus.DocumentSigned,
|
|
}, cancel);
|
|
}
|
|
} |