Update Culture model and DI for non-nullable properties

Refactored Culture model to use required and non-nullable properties.
Removed nullable checks for Info in ShowEnvelope.cshtml.
Changed DI from Cultures to MultiCulture in _ViewImports.cshtml.
This commit is contained in:
2026-02-12 17:16:36 +01:00
parent bcf55f7906
commit 0e270e3182
3 changed files with 13 additions and 8 deletions

View File

@@ -4,15 +4,20 @@ namespace EnvelopeGenerator.Web.Models
{ {
public class Culture public class Culture
{ {
private string _language = string.Empty; private string _language = null!;
public string Language { get => _language;
init { public required string Language
{
get => _language;
init
{
_language = value; _language = value;
Info = new(value); Info = new(value);
} }
} }
public string FIClass { get; init; } = string.Empty;
public CultureInfo? Info { get; init; } public string FIClass { get; init; } = null!;
public CultureInfo Info { get; init; } = null!;
} }
} }

View File

@@ -86,7 +86,7 @@
<p> <p>
<small class="text-body-secondary"> <small class="text-body-secondary">
@Html.Raw(_localizer.EnvelopeInfo2().Format( @Html.Raw(_localizer.EnvelopeInfo2().Format(
envelope?.AddedWhen.ToString(userCulture?.Info?.DateTimeFormat), envelope?.AddedWhen.ToString(userCulture?.Info.DateTimeFormat),
$"{sender?.Prename} {sender?.Name}", $"{sender?.Prename} {sender?.Name}",
sender?.Email, sender?.Email,
envelope?.Title, envelope?.Title,
@@ -216,6 +216,6 @@
var documentBase64String = Convert.ToBase64String(documentBytes); var documentBase64String = Convert.ToBase64String(documentBytes);
var envelopeKey = ViewData["EnvelopeKey"] as string; var envelopeKey = ViewData["EnvelopeKey"] as string;
@:document.addEventListener("DOMContentLoaded", async () => await new App("@envelopeKey", @Html.Raw(envelopeReceiverJson), B64ToBuff("@Html.Raw(documentBase64String)"), "@ViewData["PSPDFKitLicenseKey"]", "@userCulture?.Info?.TwoLetterISOLanguageName").init()) @:document.addEventListener("DOMContentLoaded", async () => await new App("@envelopeKey", @Html.Raw(envelopeReceiverJson), B64ToBuff("@Html.Raw(documentBase64String)"), "@ViewData["PSPDFKitLicenseKey"]", "@userCulture?.Info.TwoLetterISOLanguageName").init())
} }
</script> </script>

View File

@@ -7,6 +7,6 @@
@using Microsoft.Extensions.Options @using Microsoft.Extensions.Options
@inject IStringLocalizer<Resource> _localizer @inject IStringLocalizer<Resource> _localizer
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor _accessor @inject Microsoft.AspNetCore.Http.IHttpContextAccessor _accessor
@inject Cultures _cultures @inject MultiCulture _cultures
@inject IOptions<CustomImages> _cImgOpt @inject IOptions<CustomImages> _cImgOpt
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers