90 lines
2.5 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Drawing;
#if NETFRAMEWORK
using System;
using System.Collections.Generic;
#endif
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_RECEIVER", Schema = "dbo")]
public class Receiver
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Id { get; set; }
[Required, EmailAddress]
[Column("EMAIL_ADDRESS", TypeName = "nvarchar(250)")]
[StringLength(250)]
public string EmailAddress { get; set; }
[Required]
[Column("SIGNATURE", TypeName = "nvarchar(64)")]
public string Signature { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[Column("TOTP_SECRET_KEY", TypeName = "nvarchar(MAX)")]
public string TotpSecretkey { get; set; }
[Column("TFA_REG_DEADLINE", TypeName = "datetime")]
public DateTime? TfaRegDeadline { get; set; }
public List<EnvelopeReceiver> EnvelopeReceivers { get; set; }
[NotMapped]
public string Name { get; set; }
[NotMapped]
public string Company { get; set; } = string.Empty;
[NotMapped]
public string JobTitle { get; set; } = string.Empty;
[NotMapped]
public string PhoneNumber { get; set; } = string.Empty;
[NotMapped]
public string AccessCode { get; set; } = string.Empty;
[NotMapped]
public string PrivateMessage { get; set; } = string.Empty;
[NotMapped]
public int Sequence { get; set; } = 0;
[NotMapped]
public DateTime SignedDate { get; set; } = DateTime.MinValue;
[NotMapped]
public Constants.ReceiverStatus Status { get; set; }
[NotMapped]
public Constants.ColorType ColorType { get; set; }
[NotMapped]
public bool HasId => Id > 0;
[NotMapped]
public bool HasEmailAndName =>
!string.IsNullOrWhiteSpace(EmailAddress) &&
!string.IsNullOrWhiteSpace(Name);
[NotMapped]
public string SignedDateDisplayValue =>
SignedDate == DateTime.MinValue ? "-" : SignedDate.ToString("G");
[NotMapped]
public Color Color => ColorType.ToColor();
public string GetSignature()
{
return EmailAddress.ToUpperInvariant().GetChecksum();
}
}
}