Refactor: Remove CertificationType and ContractType

Removed `CertificationType` and `ContractType` properties and logic across the codebase as they were redundant. Updated `EnvelopeType` to include a validation extension method for improved data integrity. Refactored `CreateEnvelopeWizardPopup.razor` and other UI components to simplify handling of `EnvelopeType`.

Conditionally included `CertificationType` and `ContractType` for `NETFRAMEWORK` targets using `#if NETFRAMEWORK` directives to ensure compatibility. Removed unused enums, imports, and methods. Updated `CreateEnvelopeCommandHandler` and related classes to reflect these changes.
This commit is contained in:
2026-11-13 11:06:12 +01:00
parent 67e435c3fa
commit 13784cd595
17 changed files with 79 additions and 131 deletions

View File

@@ -1,4 +1,5 @@
namespace EnvelopeGenerator.Domain.Constants
#if NETFRAMEWORK
namespace EnvelopeGenerator.Domain.Constants
{
public enum CertificationType
{
@@ -6,3 +7,4 @@
ElectronicSignature = 2
}
}
#endif

View File

@@ -1,8 +1,10 @@
namespace EnvelopeGenerator.Domain.Constants
#if NETFRAMEWORK
namespace EnvelopeGenerator.Domain.Constants
{
public enum ContractType
{
Contract = 1,
ReadAndSign = 2
}
}
}
#endif

View File

@@ -1,4 +1,11 @@
namespace EnvelopeGenerator.Domain.Constants
#if NETFRAMEWORK
using System;
using System.Linq;
#endif
using EnvelopeGenerator.Domain.Exceptions;
namespace EnvelopeGenerator.Domain.Constants
{
public enum EnvelopeType
{
@@ -6,4 +13,28 @@
ReadAndConfirm = 2,
AdvancedSignature = 3
}
public static class EnvelopeTypeExtensions
{
public static EnvelopeType ToEnvelopeType(this int envelopeTypeId)
{
if (!Enum.IsDefined(typeof(EnvelopeType), envelopeTypeId))
{
#if NETFRAMEWORK
var values = Enum.GetValues(typeof(EnvelopeType)).Cast<EnvelopeType>();
#else
var values = Enum.GetValues<EnvelopeType>();
#endif
var validValues = string.Join(", ", values.Select(value => $"{(int)value} = {value}"));
throw new DataIntegrityException(
$"Invalid EnvelopeTypeId '{envelopeTypeId}' for envelope. " +
$"Valid {nameof(EnvelopeType)} values are: [{validValues}]. " +
"This indicates a data integrity issue: the envelope may have been " +
"created or updated with an invalid EnvelopeTypeId in the database.");
}
return (EnvelopeType)Enum.ToObject(typeof(EnvelopeType), envelopeTypeId);
}
}
}

View File

@@ -82,8 +82,11 @@ namespace EnvelopeGenerator.Domain.Entities
[Column("COMMENT", TypeName = "nvarchar(128)")]
public string Comment { get; set; }
#if NETFRAMEWORK
[Column("CONTRACT_TYPE")]
public ContractType? ContractType { get; set; }
#endif
#if NETFRAMEWORK
[NotMapped]
@@ -110,8 +113,11 @@ namespace EnvelopeGenerator.Domain.Entities
[Obsolete("Use EnvelopeGenerator.Domain.Interfaces.EnvelopeExtensions.IsReadAndConfirm extension method instead.")]
public bool ReadOnly => this.IsReadAndConfirm();
#if NETFRAMEWORK
[Column("CERTIFICATION_TYPE")]
public CertificationType? CertificationType { get; set; }
#endif
[Column("USE_ACCESS_CODE")]
public bool? UseAccessCode { get; set; }

View File

@@ -26,17 +26,19 @@ namespace EnvelopeGenerator.Domain.Entities
[Column("EXPIRES_DAYS")]
public int? ExpiresDays { get; set; }
#if NETFRAMEWORK
[Column("CERTIFICATION_TYPE")]
public Constants.CertificationType? CertificationType { get; set; }
public CertificationType? CertificationType { get; set; }
#endif
[Column("USE_ACCESS_CODE")]
public bool? UseAccessCode { get; set; }
[Column("FINAL_EMAIL_TO_CREATOR")]
public Constants.FinalEmailType? FinalEmailToCreator { get; set; }
public FinalEmailType? FinalEmailToCreator { get; set; }
[Column("FINAL_EMAIL_TO_RECEIVERS")]
public Constants.FinalEmailType? FinalEmailToReceivers { get; set; }
public FinalEmailType? FinalEmailToReceivers { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
@@ -57,8 +59,10 @@ namespace EnvelopeGenerator.Domain.Entities
[Column("REMINDER_INTERVAL_DAYS")]
public int? ReminderIntervalDays { get; set; }
#if NETFRAMEWORK
[Column("CONTRACT_TYPE")]
public ContractType? ContractType { get; set; }
#endif
[NotMapped]
public bool TFA_Enabled { get; set; } = false;

View File

@@ -35,25 +35,11 @@ namespace EnvelopeGenerator.Domain.Interfaces
return envelope.DocResult != null;
}
public static EnvelopeType Type(this IEnvelope envelope)
public static EnvelopeType? Type(this IEnvelope envelope)
{
if (!Enum.IsDefined(typeof(EnvelopeType), envelope.EnvelopeTypeId))
{
#if NETFRAMEWORK
var values = Enum.GetValues(typeof(EnvelopeType)).Cast<EnvelopeType>();
#else
var values = Enum.GetValues<EnvelopeType>();
#endif
var validValues = string.Join(", ", values.Select(value => $"{(int)value} = {value}"));
throw new DataIntegrityException(
$"Invalid EnvelopeTypeId '{envelope.EnvelopeTypeId}' for envelope. " +
$"Valid {nameof(EnvelopeType)} values are: [{validValues}]. " +
"This indicates a data integrity issue: the envelope may have been " +
"created or updated with an invalid EnvelopeTypeId in the database.");
}
return (EnvelopeType)Enum.ToObject(typeof(EnvelopeType), envelope.EnvelopeTypeId);
if (envelope.EnvelopeTypeId is int envelopeTypeId)
return envelopeTypeId.ToEnvelopeType();
return null;
}
public static void SetType(this IEnvelope envelope, EnvelopeType type)