Updated namespaces from `Signature` to `Signatures` for consistency and clarity across the application. Simplified pipeline behavior registrations in `DependencyInjection.cs` by using shorter references. Added `Microsoft.Extensions.Configuration` to `DependencyInjection.cs` to support configuration functionality. Ensured all references to `SignCommand` and related behaviors align with the new namespace structure.
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using MediatR;
|
|
using EnvelopeGenerator.Application.Common.Dto;
|
|
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
|
|
using EnvelopeGenerator.Application.Common.Extensions;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
|
|
namespace EnvelopeGenerator.Application.Signatures.Commands;
|
|
|
|
/// <summary>
|
|
/// Command to sign a document by a receiver.
|
|
/// </summary>
|
|
public record SignCommand : IRequest
|
|
{
|
|
/// <summary>
|
|
/// The envelope receiver information.
|
|
/// </summary>
|
|
public required EnvelopeReceiverDto EnvelopeReceiver { get; init; }
|
|
|
|
/// <summary>
|
|
/// The PSPDFKit annotation data.
|
|
/// </summary>
|
|
[Obsolete("This notification is deprecated. Use Signature.Commands.SignCommand instead.")]
|
|
public PsPdfKitAnnotation? PsPdfKitAnnotation { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the email template type.
|
|
/// </summary>
|
|
public EmailTemplateType TemplateType => EmailTemplateType.DocumentSigned;
|
|
|
|
/// <summary>
|
|
/// Gets the email address of the receiver.
|
|
/// </summary>
|
|
public string EmailAddress => EnvelopeReceiver.Receiver?.EmailAddress
|
|
?? throw new InvalidOperationException($"Receiver is null." +
|
|
$"DocSignedNotification:\n{this.ToJson(Format.Json.ForDiagnostics)}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handles the sign command. The actual work is done by SignCommandBehavior pipeline.
|
|
/// </summary>
|
|
public class SignCommandHandler : IRequestHandler<SignCommand>
|
|
{
|
|
/// <summary>
|
|
/// Executes the signing command. Pipeline behaviors handle the actual processing.
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public Task Handle(SignCommand request, CancellationToken cancellationToken = default)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
} |