From 7222f7e9a7e19af1d5aa2e27d1e1b40498d79925 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 29 Oct 2026 13:11:44 +0100 Subject: [PATCH] Refactor ContractType to use enum Changed the `ContractType` property in `EnvelopeDto`, `CreateEnvelopeCommandHandler`, and `Envelope` classes from a nullable `int` to a nullable `ContractType` enum. This improves type safety and consistency across the codebase by using a specific enum type instead of a generic integer. Updated logic in `CreateEnvelopeCommandHandler` to remove unnecessary casting. --- EnvelopeGenerator.Application/Common/Dto/EnvelopeDto.cs | 2 +- .../Envelopes/Commands/CreateEnvelopeCommandHandler.cs | 4 ++-- EnvelopeGenerator.Domain/Entities/Envelope.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/EnvelopeGenerator.Application/Common/Dto/EnvelopeDto.cs b/EnvelopeGenerator.Application/Common/Dto/EnvelopeDto.cs index a1fd893b..08068066 100644 --- a/EnvelopeGenerator.Application/Common/Dto/EnvelopeDto.cs +++ b/EnvelopeGenerator.Application/Common/Dto/EnvelopeDto.cs @@ -62,7 +62,7 @@ public record EnvelopeDto : IEnvelope /// /// /// - public int? ContractType { get; set; } + public ContractType? ContractType { get; set; } /// /// Default value is 'de-DE' diff --git a/EnvelopeGenerator.Application/Envelopes/Commands/CreateEnvelopeCommandHandler.cs b/EnvelopeGenerator.Application/Envelopes/Commands/CreateEnvelopeCommandHandler.cs index 5097fda5..33134c80 100644 --- a/EnvelopeGenerator.Application/Envelopes/Commands/CreateEnvelopeCommandHandler.cs +++ b/EnvelopeGenerator.Application/Envelopes/Commands/CreateEnvelopeCommandHandler.cs @@ -302,7 +302,7 @@ public class CreateEnvelopeCommandHandler : IRequestHandler 0 ? DateTime.Now.AddDays(expiresWarningWhenDays) : null, ContractType: existing?.ContractType ?? selectedType?.ContractType - ?? (int)ContractType.Contract); + ?? ContractType.Contract); } private static string ResolveLanguage(string? preferred, string? fallback1, string? fallback2) @@ -333,7 +333,7 @@ public class CreateEnvelopeCommandHandler : IRequestHandler ResolveSenderReferenceAsync(Envelope envelope, CancellationToken cancel) { diff --git a/EnvelopeGenerator.Domain/Entities/Envelope.cs b/EnvelopeGenerator.Domain/Entities/Envelope.cs index dbeb2616..1e2f7980 100644 --- a/EnvelopeGenerator.Domain/Entities/Envelope.cs +++ b/EnvelopeGenerator.Domain/Entities/Envelope.cs @@ -83,7 +83,7 @@ namespace EnvelopeGenerator.Domain.Entities public string Comment { get; set; } [Column("CONTRACT_TYPE")] - public int? ContractType { get; set; } + public ContractType? ContractType { get; set; } #if NETFRAMEWORK [NotMapped]