refactor(Envelope): Standardwerte in der Envelope-Entity in den Konstruktor verschoben
This commit is contained in:
@@ -8,176 +8,170 @@ using System.Linq;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Domain.Entities
|
namespace EnvelopeGenerator.Domain.Entities
|
||||||
|
#if NET
|
||||||
|
;
|
||||||
|
#elif NETFRAMEWORK
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
[Table("TBSIG_ENVELOPE", Schema = "dbo")]
|
||||||
|
public class Envelope
|
||||||
{
|
{
|
||||||
[Table("TBSIG_ENVELOPE", Schema = "dbo")]
|
public Envelope()
|
||||||
public class Envelope
|
|
||||||
{
|
{
|
||||||
// TODO: * Check the Form App and remove the default value
|
// TODO: * Check the Form App and remove the default value
|
||||||
[Key]
|
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
||||||
[Column("GUID")]
|
|
||||||
public int Id { get; set; } = 0;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
[Column("USER_ID")]
|
|
||||||
public int UserId { get; set; }
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Required]
|
|
||||||
[Column("STATUS")]
|
|
||||||
public int Status { get; set; } = (int)Constants.EnvelopeStatus.EnvelopeCreated;
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public string StatusName => ((Constants.EnvelopeStatus)Status).ToString();
|
|
||||||
|
|
||||||
// TODO: The default value is set to 0. Check the Form App to remove this
|
|
||||||
[Required]
|
|
||||||
[Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")]
|
|
||||||
public string Uuid { get; set; } = Guid.NewGuid().ToString();
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("MESSAGE", TypeName = "nvarchar(max)")]
|
|
||||||
public string Message { get; set; }
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
= My.Resources.Envelope.Please_read_and_sign_this_document;
|
Id = 0;
|
||||||
|
Status = (int)Constants.EnvelopeStatus.EnvelopeCreated;
|
||||||
|
Uuid = Guid.NewGuid().ToString();
|
||||||
|
Message = My.Resources.Envelope.Please_read_and_sign_this_document;
|
||||||
|
Title= string.Empty;
|
||||||
|
Comment = string.Empty;
|
||||||
|
Language = "de-DE";
|
||||||
|
SendReminderEmails = false;
|
||||||
|
FirstReminderDays = 0;
|
||||||
|
ReminderIntervalDays = 0;
|
||||||
|
CertificationType = (int)Constants.CertificationType.AdvancedElectronicSignature;
|
||||||
|
UseAccessCode = false;
|
||||||
|
Documents = Enumerable.Empty<EnvelopeDocument>().ToList();
|
||||||
|
History = Enumerable.Empty<EnvelopeHistory>().ToList();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[Column("EXPIRES_WHEN", TypeName = "datetime")]
|
|
||||||
public DateTime? ExpiresWhen { get; set; }
|
|
||||||
|
|
||||||
[Column("EXPIRES_WARNING_WHEN", TypeName = "datetime")]
|
|
||||||
public DateTime? ExpiresWarningWhen { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
|
||||||
public DateTime AddedWhen { get; set; }
|
|
||||||
|
|
||||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
|
||||||
public DateTime? ChangedWhen { get; set; }
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("TITLE", TypeName = "nvarchar(128)")]
|
|
||||||
public string
|
|
||||||
#if NET
|
|
||||||
?
|
|
||||||
#endif
|
|
||||||
Title { get; set; }
|
|
||||||
#if NETFRAMEWORK
|
|
||||||
= string.Empty;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[Column("COMMENT", TypeName = "nvarchar(128)")]
|
|
||||||
public string Comment { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Column("CONTRACT_TYPE")]
|
|
||||||
public int? ContractType { get; set; }
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
#if NETFRAMEWORK
|
|
||||||
[NotMapped]
|
|
||||||
public string ContractTypeTranslated => My.Resources.Model.ResourceManager.GetString(ContractType.ToString());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("LANGUAGE", TypeName = "nvarchar(5)")]
|
|
||||||
public string Language { get; set; } = "de-DE";
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("SEND_REMINDER_EMAILS")]
|
|
||||||
public bool SendReminderEmails { get; set; } = false;
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("FIRST_REMINDER_DAYS")]
|
|
||||||
public int? FirstReminderDays { get; set; } = 0;
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("REMINDER_INTERVAL_DAYS")]
|
|
||||||
public int? ReminderIntervalDays { get; set; } = 0;
|
|
||||||
|
|
||||||
[Column("ENVELOPE_TYPE")]
|
|
||||||
public int? EnvelopeTypeId { get; set; }
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("CERTIFICATION_TYPE")]
|
|
||||||
public int? CertificationType { get; set; } = (int)Constants.CertificationType.AdvancedElectronicSignature;
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("USE_ACCESS_CODE")]
|
|
||||||
public bool UseAccessCode { get; set; } = false;
|
|
||||||
|
|
||||||
[Column("FINAL_EMAIL_TO_CREATOR")]
|
|
||||||
public int? FinalEmailToCreator { get; set; }
|
|
||||||
|
|
||||||
[Column("FINAL_EMAIL_TO_RECEIVERS")]
|
|
||||||
public int? FinalEmailToReceivers { get; set; }
|
|
||||||
|
|
||||||
[Column("EXPIRES_WHEN_DAYS")]
|
|
||||||
public int? ExpiresWhenDays { get; set; }
|
|
||||||
|
|
||||||
[Column("EXPIRES_WARNING_WHEN_DAYS")]
|
|
||||||
public int? ExpiresWarningWhenDays { get; set; }
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[Column("TFA_ENABLED", TypeName = "bit")]
|
|
||||||
public bool TFAEnabled { get; set; } = false;
|
|
||||||
|
|
||||||
[Column("DOC_RESULT", TypeName = "varbinary(max)")]
|
|
||||||
public byte[] DocResult { get; set; }
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public string CURRENT_WORK_APP { get; set; } = "signFLOW GUI";
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[ForeignKey("UserId")]
|
|
||||||
public User User { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey("EnvelopeTypeId")]
|
|
||||||
public EnvelopeType EnvelopeType { get; set; }
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public string EnvelopeTypeTitle => EnvelopeType?.Title;
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public bool IsAlreadySent => Status > (int)Constants.EnvelopeStatus.EnvelopeSaved;
|
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
|
||||||
[NotMapped]
|
|
||||||
public string StatusTranslated => My.Resources.Model.ResourceManager.GetString(((Constants.EnvelopeStatus)Status).ToString());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public bool TFA_Enabled { get; set; } = false;
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public byte[] DOC_RESULT { get; set; }
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
public List<EnvelopeDocument> Documents { get; set; } = new List<EnvelopeDocument>();
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
public List<EnvelopeHistory> History { get; set; } = new List<EnvelopeHistory>();
|
|
||||||
|
|
||||||
// TODO: * Check the Form App and remove the default value
|
|
||||||
[NotMapped]
|
|
||||||
public List<Receiver> Receivers { get; set; } = new List<Receiver>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Validates whether the receiver and document data are complete.
|
|
||||||
/// </summary>
|
|
||||||
public List<string> ValidateReceiverDocumentData()
|
|
||||||
{
|
|
||||||
var errors = new List<string>();
|
|
||||||
|
|
||||||
if (!Documents?.Any() ?? true)
|
|
||||||
errors.Add(My.Resources.Envelope.Missing_Documents);
|
|
||||||
|
|
||||||
if (!Receivers?.Any() ?? true)
|
|
||||||
errors.Add(My.Resources.Envelope.Missing_Receivers);
|
|
||||||
|
|
||||||
if (Receivers?.Any(r => !r.HasEmailAndName) ?? false)
|
|
||||||
errors.Add(My.Resources.Envelope.Incomplete_Receivers);
|
|
||||||
|
|
||||||
return errors;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
[Column("GUID")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[Column("USER_ID")]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[Column("STATUS")]
|
||||||
|
public int Status { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")]
|
||||||
|
public string Uuid { get; set; }
|
||||||
|
|
||||||
|
[Column("MESSAGE", TypeName = "nvarchar(max)")]
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
[Column("EXPIRES_WHEN", TypeName = "datetime")]
|
||||||
|
public DateTime? ExpiresWhen { get; set; }
|
||||||
|
|
||||||
|
[Column("EXPIRES_WARNING_WHEN", TypeName = "datetime")]
|
||||||
|
public DateTime? ExpiresWarningWhen { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||||
|
public DateTime AddedWhen { get; set; }
|
||||||
|
|
||||||
|
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||||
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
|
||||||
|
[Column("TITLE", TypeName = "nvarchar(128)")]
|
||||||
|
public string
|
||||||
|
#if NET
|
||||||
|
?
|
||||||
|
#endif
|
||||||
|
Title { get; set; }
|
||||||
|
|
||||||
|
[Column("COMMENT", TypeName = "nvarchar(128)")]
|
||||||
|
public string Comment { get; set; }
|
||||||
|
|
||||||
|
[Column("CONTRACT_TYPE")]
|
||||||
|
public int? ContractType { get; set; }
|
||||||
|
|
||||||
|
#if NETFRAMEWORK
|
||||||
|
[NotMapped]
|
||||||
|
public string ContractTypeTranslated => My.Resources.Model.ResourceManager.GetString(ContractType.ToString());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
[Column("LANGUAGE", TypeName = "nvarchar(5)")]
|
||||||
|
public string Language { get; set; }
|
||||||
|
|
||||||
|
[Column("SEND_REMINDER_EMAILS")]
|
||||||
|
public bool SendReminderEmails { get; set; }
|
||||||
|
|
||||||
|
[Column("FIRST_REMINDER_DAYS")]
|
||||||
|
public int? FirstReminderDays { get; set; }
|
||||||
|
|
||||||
|
[Column("REMINDER_INTERVAL_DAYS")]
|
||||||
|
public int? ReminderIntervalDays { get; set; }
|
||||||
|
|
||||||
|
[Column("ENVELOPE_TYPE")]
|
||||||
|
public int? EnvelopeTypeId { get; set; }
|
||||||
|
|
||||||
|
[Column("CERTIFICATION_TYPE")]
|
||||||
|
public int? CertificationType { get; set; }
|
||||||
|
|
||||||
|
[Column("USE_ACCESS_CODE")]
|
||||||
|
public bool UseAccessCode { get; set; }
|
||||||
|
|
||||||
|
[Column("FINAL_EMAIL_TO_CREATOR")]
|
||||||
|
public int? FinalEmailToCreator { get; set; }
|
||||||
|
|
||||||
|
[Column("FINAL_EMAIL_TO_RECEIVERS")]
|
||||||
|
public int? FinalEmailToReceivers { get; set; }
|
||||||
|
|
||||||
|
[Column("EXPIRES_WHEN_DAYS")]
|
||||||
|
public int? ExpiresWhenDays { get; set; }
|
||||||
|
|
||||||
|
[Column("EXPIRES_WARNING_WHEN_DAYS")]
|
||||||
|
public int? ExpiresWarningWhenDays { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("UserId")]
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("EnvelopeTypeId")]
|
||||||
|
public EnvelopeType EnvelopeType { get; set; }
|
||||||
|
|
||||||
|
#if NETFRAMEWORK
|
||||||
|
[NotMapped]
|
||||||
|
public string CURRENT_WORK_APP { get; set; } = "signFLOW GUI";
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public bool IsAlreadySent => Status > (int)Constants.EnvelopeStatus.EnvelopeSaved;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public bool TFA_Enabled { get; set; } = false;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public byte[] DOC_RESULT { get; set; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public List<EnvelopeDocument> Documents { get; set; }
|
||||||
|
|
||||||
|
public List<EnvelopeHistory> History { get; set; }
|
||||||
|
|
||||||
|
// TODO: * Check the Form App and remove the default value
|
||||||
|
[NotMapped]
|
||||||
|
public List<Receiver> Receivers { get; set; } = Enumerable.Empty<Receiver>().ToList();
|
||||||
|
|
||||||
|
#if NETFRAMEWORK
|
||||||
|
/// <summary>
|
||||||
|
/// Validates whether the receiver and document data are complete.
|
||||||
|
/// </summary>
|
||||||
|
public List<string> ValidateReceiverDocumentData()
|
||||||
|
{
|
||||||
|
var errors = new List<string>();
|
||||||
|
|
||||||
|
if (!Documents?.Any() ?? true)
|
||||||
|
errors.Add(My.Resources.Envelope.Missing_Documents);
|
||||||
|
|
||||||
|
if (!Receivers?.Any() ?? true)
|
||||||
|
errors.Add(My.Resources.Envelope.Missing_Receivers);
|
||||||
|
|
||||||
|
if (Receivers?.Any(r => !r.HasEmailAndName) ?? false)
|
||||||
|
errors.Add(My.Resources.Envelope.Incomplete_Receivers);
|
||||||
|
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if NETFRAMEWORK
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user