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:
2026-10-26 16:59:49 +01:00
parent ae1ecbc15f
commit c2b7579717
10 changed files with 26 additions and 43 deletions

View File

@@ -84,7 +84,7 @@ public record EnvelopeDto : IEnvelope
/// <summary>
///
/// </summary>
public int? CertificationType { get; set; }
public CertificationType? CertificationType { get; set; }
/// <summary>
///

View File

@@ -1,4 +1,6 @@
namespace EnvelopeGenerator.Application.Common.Dto;
using EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Application.Common.Dto;
/// <summary>
/// Data Transfer Object representing a type of envelope with its configuration settings.
@@ -28,7 +30,7 @@ public class EnvelopeTypeDto
/// <summary>
/// Gets or sets the certification type identifier.
/// </summary>
public int? CertificationType { get; set; }
public CertificationType? CertificationType { get; set; }
/// <summary>
/// Gets or sets a value indicating whether an access code is required.

View File

@@ -45,7 +45,7 @@ public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQu
Title = t.Title ?? string.Empty,
Language = string.IsNullOrWhiteSpace(t.Language) ? "de-DE" : t.Language,
ExpiresDays = t.ExpiresDays,
CertificationType = (int?)t.CertificationType,
CertificationType = t.CertificationType,
UseAccessCode = t.UseAccessCode,
FinalEmailToCreator = (int?)t.FinalEmailToCreator,
FinalEmailToReceivers = (int?)t.FinalEmailToReceivers,

View File

@@ -1,5 +1,6 @@
using EnvelopeGenerator.Application.Common.Dto;
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
using EnvelopeGenerator.Domain.Constants;
using MediatR;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -35,7 +36,7 @@ public record CreateEnvelopeCommand : IRequest<EnvelopeDto?>
/// <summary>
/// Zertifizierungstyp fuer den Signaturprozess.
/// </summary>
public int? CertificationType { get; set; }
public CertificationType? CertificationType { get; set; }
/// <summary>
/// Finale E-Mail-Einstellung fuer den Ersteller.

View File

@@ -267,10 +267,10 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
EnvelopeTypeId: request.EnvelopeTypeId ?? existing?.EnvelopeTypeId,
Language: ResolveLanguage(request.Language, selectedType?.Language, existing?.Language),
UseAccessCode: useAccessCode,
CertificationType: NormalizeCertificationType(request.CertificationType
?? (int?)selectedType?.CertificationType
CertificationType: request.CertificationType
?? selectedType?.CertificationType
?? existing?.CertificationType
?? (int)CertificationType.AdvancedElectronicSignature),
?? CertificationType.AdvancedElectronicSignature,
FinalEmailToCreator: request.FinalEmailToCreator
?? (int?)selectedType?.FinalEmailToCreator
?? existing?.FinalEmailToCreator
@@ -316,18 +316,11 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
return "de-DE";
}
private static int NormalizeCertificationType(int value)
{
return value == 2
? 2
: (int)CertificationType.AdvancedElectronicSignature;
}
private sealed record EnvelopeSettings(
int? EnvelopeTypeId,
string Language,
bool UseAccessCode,
int CertificationType,
CertificationType CertificationType,
int FinalEmailToCreator,
int FinalEmailToReceivers,
bool SendReminderEmails,