- Introduced AnnotationCreateDto for creation-specific properties - AnnotationDto now inherits from AnnotationCreateDto and includes Id, AddedWhen, ChangedWhen, and ChangedWho - Added Type property to AnnotationCreateDto - remove CreateAnnotationCommand
63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
using EnvelopeGenerator.Application.Common.Dto;
|
|
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
|
|
using EnvelopeGenerator.Application.Common.Extensions;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
using MediatR;
|
|
using System.Dynamic;
|
|
|
|
namespace EnvelopeGenerator.Application.Common.Notifications.DocSigned;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="Instant"></param>
|
|
/// <param name="Structured"></param>
|
|
public record PsPdfKitAnnotation(ExpandoObject Instant, IEnumerable<AnnotationCreateDto> Structured);
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="Original"></param>
|
|
public record DocSignedNotification(EnvelopeReceiverDto Original) : EnvelopeReceiverDto(Original), INotification, ISendMailNotification
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public PsPdfKitAnnotation PsPdfKitAnnotation { get; init; } = null!;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public EmailTemplateType TemplateType => EmailTemplateType.DocumentSigned;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string EmailAddress => Receiver?.EmailAddress
|
|
?? throw new InvalidOperationException($"Receiver is null." +
|
|
$"DocSignedNotification:\n{this.ToJson(Format.Json.ForDiagnostics)}");
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static class DocSignedNotificationExtensions
|
|
{
|
|
/// <summary>
|
|
/// Converts an <see cref="EnvelopeReceiverDto"/> to a <see cref="DocSignedNotification"/>.
|
|
/// </summary>
|
|
/// <param name="dto">The DTO to convert.</param>
|
|
/// <param name="psPdfKitAnnotation"></param>
|
|
/// <returns>A new <see cref="DocSignedNotification"/> instance.</returns>
|
|
public static DocSignedNotification ToDocSignedNotification(this EnvelopeReceiverDto dto, PsPdfKitAnnotation psPdfKitAnnotation)
|
|
=> new(dto) { PsPdfKitAnnotation = psPdfKitAnnotation };
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="dtoTask"></param>
|
|
/// <param name="psPdfKitAnnotation"></param>
|
|
/// <returns></returns>
|
|
public static async Task<DocSignedNotification?> ToDocSignedNotification(this Task<EnvelopeReceiverDto?> dtoTask, PsPdfKitAnnotation psPdfKitAnnotation)
|
|
=> await dtoTask is EnvelopeReceiverDto dto ? new(dto) { PsPdfKitAnnotation = psPdfKitAnnotation } : null;
|
|
} |