Refactor CertificationType to use enum
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.
This commit is contained in:
@@ -84,7 +84,7 @@ public record EnvelopeDto : IEnvelope
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? CertificationType { get; set; }
|
public CertificationType? CertificationType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace EnvelopeGenerator.Application.Common.Dto;
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data Transfer Object representing a type of envelope with its configuration settings.
|
/// Data Transfer Object representing a type of envelope with its configuration settings.
|
||||||
@@ -28,7 +30,7 @@ public class EnvelopeTypeDto
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the certification type identifier.
|
/// Gets or sets the certification type identifier.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? CertificationType { get; set; }
|
public CertificationType? CertificationType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether an access code is required.
|
/// Gets or sets a value indicating whether an access code is required.
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQu
|
|||||||
Title = t.Title ?? string.Empty,
|
Title = t.Title ?? string.Empty,
|
||||||
Language = string.IsNullOrWhiteSpace(t.Language) ? "de-DE" : t.Language,
|
Language = string.IsNullOrWhiteSpace(t.Language) ? "de-DE" : t.Language,
|
||||||
ExpiresDays = t.ExpiresDays,
|
ExpiresDays = t.ExpiresDays,
|
||||||
CertificationType = (int?)t.CertificationType,
|
CertificationType = t.CertificationType,
|
||||||
UseAccessCode = t.UseAccessCode,
|
UseAccessCode = t.UseAccessCode,
|
||||||
FinalEmailToCreator = (int?)t.FinalEmailToCreator,
|
FinalEmailToCreator = (int?)t.FinalEmailToCreator,
|
||||||
FinalEmailToReceivers = (int?)t.FinalEmailToReceivers,
|
FinalEmailToReceivers = (int?)t.FinalEmailToReceivers,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using EnvelopeGenerator.Application.Common.Dto;
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
|
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
|
||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
@@ -35,7 +36,7 @@ public record CreateEnvelopeCommand : IRequest<EnvelopeDto?>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Zertifizierungstyp fuer den Signaturprozess.
|
/// Zertifizierungstyp fuer den Signaturprozess.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? CertificationType { get; set; }
|
public CertificationType? CertificationType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finale E-Mail-Einstellung fuer den Ersteller.
|
/// Finale E-Mail-Einstellung fuer den Ersteller.
|
||||||
|
|||||||
@@ -267,10 +267,10 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
|
|||||||
EnvelopeTypeId: request.EnvelopeTypeId ?? existing?.EnvelopeTypeId,
|
EnvelopeTypeId: request.EnvelopeTypeId ?? existing?.EnvelopeTypeId,
|
||||||
Language: ResolveLanguage(request.Language, selectedType?.Language, existing?.Language),
|
Language: ResolveLanguage(request.Language, selectedType?.Language, existing?.Language),
|
||||||
UseAccessCode: useAccessCode,
|
UseAccessCode: useAccessCode,
|
||||||
CertificationType: NormalizeCertificationType(request.CertificationType
|
CertificationType: request.CertificationType
|
||||||
?? (int?)selectedType?.CertificationType
|
?? selectedType?.CertificationType
|
||||||
?? existing?.CertificationType
|
?? existing?.CertificationType
|
||||||
?? (int)CertificationType.AdvancedElectronicSignature),
|
?? CertificationType.AdvancedElectronicSignature,
|
||||||
FinalEmailToCreator: request.FinalEmailToCreator
|
FinalEmailToCreator: request.FinalEmailToCreator
|
||||||
?? (int?)selectedType?.FinalEmailToCreator
|
?? (int?)selectedType?.FinalEmailToCreator
|
||||||
?? existing?.FinalEmailToCreator
|
?? existing?.FinalEmailToCreator
|
||||||
@@ -316,18 +316,11 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
|
|||||||
return "de-DE";
|
return "de-DE";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int NormalizeCertificationType(int value)
|
|
||||||
{
|
|
||||||
return value == 2
|
|
||||||
? 2
|
|
||||||
: (int)CertificationType.AdvancedElectronicSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
private sealed record EnvelopeSettings(
|
private sealed record EnvelopeSettings(
|
||||||
int? EnvelopeTypeId,
|
int? EnvelopeTypeId,
|
||||||
string Language,
|
string Language,
|
||||||
bool UseAccessCode,
|
bool UseAccessCode,
|
||||||
int CertificationType,
|
CertificationType CertificationType,
|
||||||
int FinalEmailToCreator,
|
int FinalEmailToCreator,
|
||||||
int FinalEmailToReceivers,
|
int FinalEmailToReceivers,
|
||||||
bool SendReminderEmails,
|
bool SendReminderEmails,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
SendReminderEmails = false;
|
SendReminderEmails = false;
|
||||||
FirstReminderDays = 0;
|
FirstReminderDays = 0;
|
||||||
ReminderIntervalDays = 0;
|
ReminderIntervalDays = 0;
|
||||||
CertificationType = (int)Constants.CertificationType.AdvancedElectronicSignature;
|
CertificationType = Constants.CertificationType.AdvancedElectronicSignature;
|
||||||
UseAccessCode = false;
|
UseAccessCode = false;
|
||||||
Documents = Enumerable.Empty<Document>().ToList();
|
Documents = Enumerable.Empty<Document>().ToList();
|
||||||
Histories = Enumerable.Empty<History>().ToList();
|
Histories = Enumerable.Empty<History>().ToList();
|
||||||
@@ -111,7 +111,7 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
public bool ReadOnly => this.IsReadAndConfirm();
|
public bool ReadOnly => this.IsReadAndConfirm();
|
||||||
|
|
||||||
[Column("CERTIFICATION_TYPE")]
|
[Column("CERTIFICATION_TYPE")]
|
||||||
public int? CertificationType { get; set; }
|
public CertificationType? CertificationType { get; set; }
|
||||||
|
|
||||||
[Column("USE_ACCESS_CODE")]
|
[Column("USE_ACCESS_CODE")]
|
||||||
public bool? UseAccessCode { get; set; }
|
public bool? UseAccessCode { get; set; }
|
||||||
|
|||||||
@@ -420,7 +420,7 @@
|
|||||||
private string _language = "de-DE";
|
private string _language = "de-DE";
|
||||||
private bool _useAccessCode;
|
private bool _useAccessCode;
|
||||||
private bool _tfaEnabled;
|
private bool _tfaEnabled;
|
||||||
private int _certificationType = (int)CertificationType.AdvancedElectronicSignature;
|
private CertificationType _certificationType = CertificationType.AdvancedElectronicSignature;
|
||||||
private int _finalEmailToCreator = (int)FinalEmailType.No;
|
private int _finalEmailToCreator = (int)FinalEmailType.No;
|
||||||
private int _finalEmailToReceivers = (int)FinalEmailType.No;
|
private int _finalEmailToReceivers = (int)FinalEmailType.No;
|
||||||
private bool _sendReminderEmails;
|
private bool _sendReminderEmails;
|
||||||
@@ -1025,7 +1025,7 @@
|
|||||||
_useAccessCode = true;
|
_useAccessCode = true;
|
||||||
|
|
||||||
if (envelopeType.CertificationType.HasValue)
|
if (envelopeType.CertificationType.HasValue)
|
||||||
_certificationType = NormalizeCertificationType(envelopeType.CertificationType.Value);
|
_certificationType = envelopeType.CertificationType.Value;
|
||||||
|
|
||||||
if (envelopeType.FinalEmailToCreator.HasValue)
|
if (envelopeType.FinalEmailToCreator.HasValue)
|
||||||
_finalEmailToCreator = envelopeType.FinalEmailToCreator.Value;
|
_finalEmailToCreator = envelopeType.FinalEmailToCreator.Value;
|
||||||
@@ -1054,7 +1054,6 @@
|
|||||||
private void NormalizeSettings()
|
private void NormalizeSettings()
|
||||||
{
|
{
|
||||||
_language = string.IsNullOrWhiteSpace(_language) ? "de-DE" : _language.Trim();
|
_language = string.IsNullOrWhiteSpace(_language) ? "de-DE" : _language.Trim();
|
||||||
_certificationType = NormalizeCertificationType(_certificationType);
|
|
||||||
|
|
||||||
if (_tfaEnabled)
|
if (_tfaEnabled)
|
||||||
_useAccessCode = true;
|
_useAccessCode = true;
|
||||||
@@ -1068,13 +1067,6 @@
|
|||||||
_expiresWarningWhenDays = _expiresWhenDays;
|
_expiresWarningWhenDays = _expiresWhenDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int NormalizeCertificationType(int value)
|
|
||||||
{
|
|
||||||
return value == 2
|
|
||||||
? 2
|
|
||||||
: (int)CertificationType.AdvancedElectronicSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool ValidateSettings(out string? message)
|
private bool ValidateSettings(out string? message)
|
||||||
{
|
{
|
||||||
NormalizeSettings();
|
NormalizeSettings();
|
||||||
@@ -1123,7 +1115,7 @@
|
|||||||
_language = "de-DE";
|
_language = "de-DE";
|
||||||
_useAccessCode = false;
|
_useAccessCode = false;
|
||||||
_tfaEnabled = false;
|
_tfaEnabled = false;
|
||||||
_certificationType = (int)CertificationType.AdvancedElectronicSignature;
|
_certificationType = CertificationType.AdvancedElectronicSignature;
|
||||||
_finalEmailToCreator = (int)FinalEmailType.No;
|
_finalEmailToCreator = (int)FinalEmailType.No;
|
||||||
_finalEmailToReceivers = (int)FinalEmailType.No;
|
_finalEmailToReceivers = (int)FinalEmailType.No;
|
||||||
_sendReminderEmails = false;
|
_sendReminderEmails = false;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Server.Client.Components.Sender;
|
namespace EnvelopeGenerator.Server.Client.Components.Sender;
|
||||||
|
|
||||||
public sealed record CreateEnvelopeWizardResult(
|
public sealed record CreateEnvelopeWizardResult(
|
||||||
@@ -7,7 +9,7 @@ public sealed record CreateEnvelopeWizardResult(
|
|||||||
string Language,
|
string Language,
|
||||||
bool UseAccessCode,
|
bool UseAccessCode,
|
||||||
bool TFAEnabled,
|
bool TFAEnabled,
|
||||||
int CertificationType,
|
CertificationType CertificationType,
|
||||||
int FinalEmailToCreator,
|
int FinalEmailToCreator,
|
||||||
int FinalEmailToReceivers,
|
int FinalEmailToReceivers,
|
||||||
bool SendReminderEmails,
|
bool SendReminderEmails,
|
||||||
|
|||||||
@@ -652,7 +652,7 @@
|
|||||||
string _language = "de-DE";
|
string _language = "de-DE";
|
||||||
bool _useAccessCode;
|
bool _useAccessCode;
|
||||||
bool _tfaEnabled;
|
bool _tfaEnabled;
|
||||||
int _certificationType = (int)CertificationType.AdvancedElectronicSignature;
|
CertificationType _certificationType = CertificationType.AdvancedElectronicSignature;
|
||||||
int _finalEmailToCreator = (int)FinalEmailType.No;
|
int _finalEmailToCreator = (int)FinalEmailType.No;
|
||||||
int _finalEmailToReceivers = (int)FinalEmailType.No;
|
int _finalEmailToReceivers = (int)FinalEmailType.No;
|
||||||
bool _sendReminderEmails;
|
bool _sendReminderEmails;
|
||||||
@@ -745,7 +745,7 @@
|
|||||||
_language = string.IsNullOrWhiteSpace(payload.Language) ? "de-DE" : payload.Language;
|
_language = string.IsNullOrWhiteSpace(payload.Language) ? "de-DE" : payload.Language;
|
||||||
_useAccessCode = payload.UseAccessCode;
|
_useAccessCode = payload.UseAccessCode;
|
||||||
_tfaEnabled = payload.TFAEnabled;
|
_tfaEnabled = payload.TFAEnabled;
|
||||||
_certificationType = NormalizeCertificationType(payload.CertificationType);
|
_certificationType = payload.CertificationType;
|
||||||
_finalEmailToCreator = payload.FinalEmailToCreator;
|
_finalEmailToCreator = payload.FinalEmailToCreator;
|
||||||
_finalEmailToReceivers = payload.FinalEmailToReceivers;
|
_finalEmailToReceivers = payload.FinalEmailToReceivers;
|
||||||
_sendReminderEmails = payload.SendReminderEmails;
|
_sendReminderEmails = payload.SendReminderEmails;
|
||||||
@@ -852,7 +852,7 @@
|
|||||||
if (_tfaEnabled)
|
if (_tfaEnabled)
|
||||||
_useAccessCode = true;
|
_useAccessCode = true;
|
||||||
|
|
||||||
_certificationType = NormalizeCertificationType(envelope.CertificationType ?? (int)CertificationType.AdvancedElectronicSignature);
|
_certificationType = envelope.CertificationType ?? CertificationType.AdvancedElectronicSignature;
|
||||||
_finalEmailToCreator = envelope.FinalEmailToCreator ?? (int)FinalEmailType.No;
|
_finalEmailToCreator = envelope.FinalEmailToCreator ?? (int)FinalEmailType.No;
|
||||||
_finalEmailToReceivers = envelope.FinalEmailToReceivers ?? (int)FinalEmailType.No;
|
_finalEmailToReceivers = envelope.FinalEmailToReceivers ?? (int)FinalEmailType.No;
|
||||||
|
|
||||||
@@ -1046,7 +1046,7 @@
|
|||||||
_useAccessCode = true;
|
_useAccessCode = true;
|
||||||
|
|
||||||
if (envelopeType.CertificationType.HasValue)
|
if (envelopeType.CertificationType.HasValue)
|
||||||
_certificationType = NormalizeCertificationType(envelopeType.CertificationType.Value);
|
_certificationType = envelopeType.CertificationType.Value;
|
||||||
|
|
||||||
if (envelopeType.FinalEmailToCreator.HasValue)
|
if (envelopeType.FinalEmailToCreator.HasValue)
|
||||||
_finalEmailToCreator = envelopeType.FinalEmailToCreator.Value;
|
_finalEmailToCreator = envelopeType.FinalEmailToCreator.Value;
|
||||||
@@ -1433,7 +1433,6 @@
|
|||||||
void NormalizeSettings()
|
void NormalizeSettings()
|
||||||
{
|
{
|
||||||
_language = string.IsNullOrWhiteSpace(_language) ? "de-DE" : _language.Trim();
|
_language = string.IsNullOrWhiteSpace(_language) ? "de-DE" : _language.Trim();
|
||||||
_certificationType = NormalizeCertificationType(_certificationType);
|
|
||||||
|
|
||||||
if (_tfaEnabled)
|
if (_tfaEnabled)
|
||||||
_useAccessCode = true;
|
_useAccessCode = true;
|
||||||
@@ -1447,13 +1446,6 @@
|
|||||||
_expiresWarningWhenDays = _expiresWhenDays;
|
_expiresWarningWhenDays = _expiresWhenDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int NormalizeCertificationType(int value)
|
|
||||||
{
|
|
||||||
return value == 2
|
|
||||||
? 2
|
|
||||||
: (int)CertificationType.AdvancedElectronicSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValidateSettings(out string? message)
|
bool ValidateSettings(out string? message)
|
||||||
{
|
{
|
||||||
NormalizeSettings();
|
NormalizeSettings();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Server.Client.Services;
|
namespace EnvelopeGenerator.Server.Client.Services;
|
||||||
@@ -49,7 +50,7 @@ public sealed record CreateEnvelopeBootstrapPayload(
|
|||||||
string Language,
|
string Language,
|
||||||
bool UseAccessCode,
|
bool UseAccessCode,
|
||||||
bool TFAEnabled,
|
bool TFAEnabled,
|
||||||
int CertificationType,
|
CertificationType CertificationType,
|
||||||
int FinalEmailToCreator,
|
int FinalEmailToCreator,
|
||||||
int FinalEmailToReceivers,
|
int FinalEmailToReceivers,
|
||||||
bool SendReminderEmails,
|
bool SendReminderEmails,
|
||||||
|
|||||||
Reference in New Issue
Block a user