Refactor namespaces for SignCommand and behaviors
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.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using EnvelopeGenerator.Application.Common.Extensions;
|
||||
using EnvelopeGenerator.Application.Histories.Commands;
|
||||
using EnvelopeGenerator.Application.Signatures.Commands;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Signatures.Behaviors;
|
||||
|
||||
/// <summary>
|
||||
/// Pipeline behavior that records history.
|
||||
/// Executes third in the signing process.
|
||||
/// </summary>
|
||||
public class HistoryBehavior : IPipelineBehavior<SignCommand, Unit>
|
||||
{
|
||||
private readonly ISender _sender;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
public HistoryBehavior(ISender sender)
|
||||
{
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="next"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Unit> Handle(SignCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.EnvelopeReceiver.Receiver is null)
|
||||
throw new InvalidOperationException($"Receiver information is missing in the notification. SignCommand:\n {request.ToJson(Format.Json.ForDiagnostics)}");
|
||||
|
||||
await _sender.Send(new CreateHistoryCommand()
|
||||
{
|
||||
EnvelopeId = request.EnvelopeReceiver.EnvelopeId,
|
||||
UserReference = request.EnvelopeReceiver.Receiver.EmailAddress,
|
||||
Status = EnvelopeStatus.DocumentSigned,
|
||||
}, cancellationToken);
|
||||
|
||||
return await next();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user