Refactored the `SignCommand` class to inherit from `EnvelopeReceiverQueryBase` and introduced a private backing field `_envelopeReceiver` for better encapsulation. Added an internal method `SetEnvelopeReceiver` to manage the envelope receiver data. Updated the `EnvelopeReceiver` property to use the backing field and removed the `required` modifier for more controlled initialization. Clarified comments in `SignCommandHandler` to emphasize that all processing is handled by pipeline behaviors, leaving the handler intentionally empty. Made minor adjustments to comments for improved clarity and consistency.
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using MediatR;
|
|
using EnvelopeGenerator.Application.Common.Dto;
|
|
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
|
|
using EnvelopeGenerator.Application.Common.Query;
|
|
|
|
namespace EnvelopeGenerator.Application.Signatures.Commands;
|
|
|
|
/// <summary>
|
|
/// Command to sign a document by a receiver.
|
|
/// </summary>
|
|
public record SignCommand : EnvelopeReceiverQueryBase, IRequest
|
|
{
|
|
private EnvelopeReceiverDto? _envelopeReceiver;
|
|
|
|
internal void SetEnvelopeReceiver(EnvelopeReceiverDto envelopeReceiver)
|
|
{
|
|
_envelopeReceiver = envelopeReceiver;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The envelope receiver information.
|
|
/// </summary>
|
|
public EnvelopeReceiverDto EnvelopeReceiver
|
|
{
|
|
get => _envelopeReceiver!;
|
|
init => _envelopeReceiver = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The PSPDFKit annotation data.
|
|
/// </summary>
|
|
[Obsolete("This notification is deprecated. Use Signature.Commands.SignCommand instead.")]
|
|
public PsPdfKitAnnotation? PsPdfKitAnnotation { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handles the sign command. All work is done by pipeline behaviors.
|
|
/// This handler is intentionally empty - behaviors handle all the processing.
|
|
/// </summary>
|
|
public class SignCommandHandler : IRequestHandler<SignCommand>
|
|
{
|
|
/// <summary>
|
|
/// Executes the signing command. Pipeline behaviors handle all processing.
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public Task Handle(SignCommand request, CancellationToken cancellationToken = default)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
} |