Refactor: Replace EnvelopeTypeId with EnvelopeType enum

Replaced all instances of `EnvelopeTypeId` (int/int?) with `Type`
(EnvelopeType/EnvelopeType?) across the codebase to improve type
safety and readability. Updated affected properties, methods, and
logic in DTOs, commands, handlers, and Razor components.

Introduced conditional compilation to handle differences between
.NET and .NET Framework where necessary. Removed obsolete helper
methods for `EnvelopeTypeId`. This refactor ensures consistent use
of the strongly-typed `EnvelopeType` enum, reducing the risk of
invalid values and aligning with best practices.
This commit is contained in:
2026-11-13 11:46:56 +01:00
parent 18fbc2100f
commit 48b2fc0eca
15 changed files with 63 additions and 56 deletions

View File

@@ -543,10 +543,11 @@
{
_validationMessage = null;
var raw = args.Value?.ToString();
if (int.TryParse(raw, out var id) && id > 0)
if (int.TryParse(raw, out var typeInt))
{
_selectedEnvelopeType = id.ToEnvelopeType();
var selectedType = EnvelopeTypes.FirstOrDefault(x => x.Id == id);
var type = typeInt.ToEnvelopeType();
_selectedEnvelopeType = type;
var selectedType = EnvelopeTypes.FirstOrDefault(x => x.Id == type);
if (selectedType is not null)
ApplyEnvelopeTypeDefaults(selectedType);
@@ -756,7 +757,7 @@
var result = new CreateEnvelopeWizardResult(
Title: _title.Trim(),
Message: _message.Trim(),
EnvelopeTypeId: (int?)_selectedEnvelopeType,
Type: _selectedEnvelopeType,
Language: string.IsNullOrWhiteSpace(_language) ? "de-DE" : _language,
UseAccessCode: _useAccessCode,
TFAEnabled: _tfaEnabled,
@@ -1085,7 +1086,7 @@
if (!_selectedEnvelopeType.HasValue)
return;
var selectedType = EnvelopeTypes.FirstOrDefault(x => x.Id == (int)_selectedEnvelopeType);
var selectedType = EnvelopeTypes.FirstOrDefault(x => x.Id == _selectedEnvelopeType);
if (selectedType is not null)
ApplyEnvelopeTypeDefaults(selectedType);
}

View File

@@ -5,7 +5,7 @@ namespace EnvelopeGenerator.Server.Client.Components.Sender;
public sealed record CreateEnvelopeWizardResult(
string Title,
string Message,
int? EnvelopeTypeId,
EnvelopeType? Type,
string Language,
bool UseAccessCode,
bool TFAEnabled,