Changed CertificationType from int? to CertificationType? enum across multiple files, including EnvelopeDto, EnvelopeTypeDto, and CreateEnvelopeCommand, to improve type safety. Removed the NormalizeCertificationType method as it is no longer necessary. Updated components and records to use the enum directly, enhancing code clarity and reducing potential errors. Added necessary using directives for the enum.
206 lines
5.8 KiB
C#
206 lines
5.8 KiB
C#
using System;
|
|
using DigitalData.UserManager.Domain.Entities;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
using Newtonsoft.Json;
|
|
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
|
using EnvelopeGenerator.Domain.Interfaces;
|
|
#if NETFRAMEWORK
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
#endif
|
|
|
|
namespace EnvelopeGenerator.Domain.Entities
|
|
{
|
|
[Table("TBSIG_ENVELOPE", Schema = "dbo")]
|
|
public class Envelope : IHasAddedWhen, IHasChangedWhen, IEnvelope
|
|
{
|
|
public Envelope()
|
|
{
|
|
// TODO: * Check the Form App and remove the default value
|
|
#if NETFRAMEWORK
|
|
Id = 0;
|
|
Status = 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 = Constants.CertificationType.AdvancedElectronicSignature;
|
|
UseAccessCode = false;
|
|
Documents = Enumerable.Empty<Document>().ToList();
|
|
Histories = Enumerable.Empty<History>().ToList();
|
|
EnvelopeReceivers = Enumerable.Empty<EnvelopeReceiver>().ToList();
|
|
#endif
|
|
}
|
|
|
|
[Key]
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
[Column("GUID")]
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
[Column("USER_ID")]
|
|
public int UserId { get; set; }
|
|
|
|
[Required]
|
|
[Column("STATUS")]
|
|
public EnvelopeStatus 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 nullable
|
|
?
|
|
#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; }
|
|
|
|
[JsonIgnore]
|
|
[NotMapped]
|
|
[Obsolete("Use EnvelopeGenerator.Domain.Interfaces.EnvelopeExtensions.IsReadAndConfirm extension method instead.")]
|
|
public bool ReadOnly => this.IsReadAndConfirm();
|
|
|
|
[Column("CERTIFICATION_TYPE")]
|
|
public CertificationType? 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; }
|
|
|
|
[Column("TFA_ENABLED")]
|
|
public bool? TfaEnabled { get; set; }
|
|
#if NETFRAMEWORK
|
|
= false;
|
|
#endif
|
|
|
|
[Column("DOC_RESULT")]
|
|
public byte[]
|
|
#if nullable
|
|
?
|
|
#endif
|
|
DocResult
|
|
{ get; set; }
|
|
|
|
[ForeignKey("EnvelopeTypeId")]
|
|
public virtual EnvelopeType
|
|
#if nullable
|
|
?
|
|
#endif
|
|
Type
|
|
{ get; set; }
|
|
|
|
#if NETFRAMEWORK
|
|
[NotMapped]
|
|
public string CURRENT_WORK_APP { get; set; } = "signFLOW GUI";
|
|
|
|
[NotMapped]
|
|
public bool IsAlreadySent => Status > EnvelopeStatus.EnvelopeSaved;
|
|
#endif
|
|
|
|
public List<Document>
|
|
#if nullable
|
|
?
|
|
#endif
|
|
Documents
|
|
{ get; set; }
|
|
|
|
public List<History>
|
|
#if nullable
|
|
?
|
|
#endif
|
|
Histories
|
|
{ get; set; }
|
|
|
|
public List<EnvelopeReceiver>
|
|
#if nullable
|
|
?
|
|
#endif
|
|
EnvelopeReceivers
|
|
{ get; set; }
|
|
|
|
//#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 (!EnvelopeReceivers?.Any() ?? true)
|
|
errors.Add(My.Resources.Envelope.Missing_Receivers);
|
|
|
|
if (EnvelopeReceivers?.Any(r => !r.HasEmailAndName) ?? false)
|
|
errors.Add(My.Resources.Envelope.Incomplete_Receivers);
|
|
|
|
return errors;
|
|
}
|
|
//#endif
|
|
}
|
|
} |