using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes;
using EnvelopeGenerator.Application.Common.Dto.Receiver;
using EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
///
///
///
public record EnvelopeReceiverDto
{
///
///
///
public EnvelopeDto? Envelope { get; set; }
///
///
///
public ReceiverDto? Receiver { get; set; }
///
///
///
public (int Envelope, int Receiver) Id => (Envelope: EnvelopeId, Receiver: ReceiverId);
///
///
///
public int EnvelopeId { get; init; }
///
///
///
public int ReceiverId { get; init; }
///
///
///
public int Sequence { get; init; }
///
///
///
[TemplatePlaceholder("[NAME_RECEIVER]")]
public string? Name { get; init; }
///
///
///
public string? JobTitle { get; init; }
///
///
///
public string? CompanyName { get; init; }
///
///
///
public string? PrivateMessage { get; init; }
///
///
///
public DateTime AddedWhen { get; init; }
///
///
///
public DateTime? ChangedWhen { get; init; }
///
///
///
public bool HasPhoneNumber { get; init; }
///
/// Indicates whether this receiver has signed the envelope.
/// Checks if there is a DocumentSigned history entry for this receiver in the envelope's history.
///
public bool Signed => Envelope?.Histories?.Any(h =>
h.Receiver?.Id == ReceiverId &&
h.Status == EnvelopeStatus.DocumentSigned
) ?? false;
}