From 1d4ad13532151d391c0a39b5a9b56bc2d2d9da37 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 30 Jan 2026 12:55:44 +0100 Subject: [PATCH] Add core model classes for auth, culture, images, and links Introduced new models in EnvelopeGenerator.GeneratorAPI.Models: - Auth, ContactLink, Culture, Cultures, CustomImages, ErrorViewModel, Image, MainViewModel, and TFARegParams. These provide foundational structures for authentication, localization, error handling, image management, and contact links. All changes are new file additions. --- EnvelopeGenerator.GeneratorAPI/Models/Auth.cs | 14 +++++ .../Models/ContactLink.cs | 60 +++++++++++++++++++ .../Models/Culture.cs | 17 ++++++ .../Models/Cultures.cs | 12 ++++ .../Models/CustomImages.cs | 6 ++ .../Models/ErrorViewModel.cs | 10 ++++ .../Models/Image.cs | 10 ++++ .../Models/MainViewModel.cs | 6 ++ .../Models/TFARegParams.cs | 17 ++++++ 9 files changed, 152 insertions(+) create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/Auth.cs create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/ContactLink.cs create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/Culture.cs create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/Cultures.cs create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/CustomImages.cs create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/ErrorViewModel.cs create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/Image.cs create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/MainViewModel.cs create mode 100644 EnvelopeGenerator.GeneratorAPI/Models/TFARegParams.cs diff --git a/EnvelopeGenerator.GeneratorAPI/Models/Auth.cs b/EnvelopeGenerator.GeneratorAPI/Models/Auth.cs new file mode 100644 index 00000000..649b75e8 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/Auth.cs @@ -0,0 +1,14 @@ +namespace EnvelopeGenerator.GeneratorAPI.Models; + +public record Auth(string? AccessCode = null, string? SmsCode = null, string? AuthenticatorCode = null, bool UserSelectSMS = default) +{ + public bool HasAccessCode => AccessCode is not null; + + public bool HasSmsCode => SmsCode is not null; + + public bool HasAuthenticatorCode => AuthenticatorCode is not null; + + public bool HasMulti => new[] { HasAccessCode, HasSmsCode, HasAuthenticatorCode }.Count(state => state) > 1; + + public bool HasNone => !(HasAccessCode || HasSmsCode || HasAuthenticatorCode); +} \ No newline at end of file diff --git a/EnvelopeGenerator.GeneratorAPI/Models/ContactLink.cs b/EnvelopeGenerator.GeneratorAPI/Models/ContactLink.cs new file mode 100644 index 00000000..b865a84c --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/ContactLink.cs @@ -0,0 +1,60 @@ +namespace EnvelopeGenerator.GeneratorAPI.Models +{ + /// + /// Represents a hyperlink for contact purposes with various HTML attributes. + /// + public class ContactLink + { + /// + /// Gets or sets the label of the hyperlink. + /// + public string Label { get; init; } = "Contact"; + + /// + /// Gets or sets the URL that the hyperlink points to. + /// + public string Href { get; set; } = string.Empty; + + /// + /// Gets or sets the target where the hyperlink should open. + /// Commonly used values are "_blank", "_self", "_parent", "_top". + /// + public string Target { get; set; } = "_blank"; + + /// + /// Gets or sets the relationship of the linked URL as space-separated link types. + /// Examples include "nofollow", "noopener", "noreferrer". + /// + public string Rel { get; set; } = string.Empty; + + /// + /// Gets or sets the filename that should be downloaded when clicking the hyperlink. + /// This attribute will only have an effect if the href attribute is set. + /// + public string Download { get; set; } = string.Empty; + + /// + /// Gets or sets the language of the linked resource. Useful when linking to + /// content in another language. + /// + public string HrefLang { get; set; } = "en"; + + /// + /// Gets or sets the MIME type of the linked URL. Helps browsers to handle + /// the type correctly when the link is clicked. + /// + public string Type { get; set; } = string.Empty; + + /// + /// Gets or sets additional information about the hyperlink, typically viewed + /// as a tooltip when the mouse hovers over the link. + /// + public string Title { get; set; } = string.Empty; + + /// + /// Gets or sets an identifier for the hyperlink, unique within the HTML document. + /// + public string Id { get; set; } = string.Empty; + } + +} diff --git a/EnvelopeGenerator.GeneratorAPI/Models/Culture.cs b/EnvelopeGenerator.GeneratorAPI/Models/Culture.cs new file mode 100644 index 00000000..fe052a15 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/Culture.cs @@ -0,0 +1,17 @@ +using System.Globalization; + +namespace EnvelopeGenerator.GeneratorAPI.Models; + +public class Culture +{ + private string _language = string.Empty; + public string Language { get => _language; + init { + _language = value; + Info = new(value); + } + } + public string FIClass { get; init; } = string.Empty; + + public CultureInfo? Info { get; init; } +} diff --git a/EnvelopeGenerator.GeneratorAPI/Models/Cultures.cs b/EnvelopeGenerator.GeneratorAPI/Models/Cultures.cs new file mode 100644 index 00000000..29bc5c50 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/Cultures.cs @@ -0,0 +1,12 @@ +namespace EnvelopeGenerator.GeneratorAPI.Models; + +public class Cultures : List +{ + public IEnumerable Languages => this.Select(c => c.Language); + + public IEnumerable FIClasses => this.Select(c => c.FIClass); + + public Culture Default => this.First(); + + public Culture? this[string? language] => language is null ? null : this.Where(c => c.Language == language).FirstOrDefault(); +} \ No newline at end of file diff --git a/EnvelopeGenerator.GeneratorAPI/Models/CustomImages.cs b/EnvelopeGenerator.GeneratorAPI/Models/CustomImages.cs new file mode 100644 index 00000000..b5863517 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/CustomImages.cs @@ -0,0 +1,6 @@ +namespace EnvelopeGenerator.GeneratorAPI.Models; + +public class CustomImages : Dictionary +{ + public new Image this[string key] => TryGetValue(key, out var img) && img is not null ? img : new(); +} \ No newline at end of file diff --git a/EnvelopeGenerator.GeneratorAPI/Models/ErrorViewModel.cs b/EnvelopeGenerator.GeneratorAPI/Models/ErrorViewModel.cs new file mode 100644 index 00000000..f1ac2093 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/ErrorViewModel.cs @@ -0,0 +1,10 @@ +namespace EnvelopeGenerator.GeneratorAPI.Models; + +public class ErrorViewModel +{ + public string Title { get; init; } = "404"; + + public string Subtitle { get; init; } = "Hmmm..."; + + public string Body { get; init; } = "It looks like one of the developers fell asleep"; +} \ No newline at end of file diff --git a/EnvelopeGenerator.GeneratorAPI/Models/Image.cs b/EnvelopeGenerator.GeneratorAPI/Models/Image.cs new file mode 100644 index 00000000..845626a3 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/Image.cs @@ -0,0 +1,10 @@ +namespace EnvelopeGenerator.GeneratorAPI.Models; + +public class Image +{ + public string Src { get; init; } = string.Empty; + + public Dictionary Classes { get; init; } = new(); + + public string GetClassIn(string page) => Classes.TryGetValue(page, out var cls) && cls is not null ? cls : string.Empty; +} \ No newline at end of file diff --git a/EnvelopeGenerator.GeneratorAPI/Models/MainViewModel.cs b/EnvelopeGenerator.GeneratorAPI/Models/MainViewModel.cs new file mode 100644 index 00000000..3764af06 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/MainViewModel.cs @@ -0,0 +1,6 @@ +namespace EnvelopeGenerator.GeneratorAPI.Models; + +public class MainViewModel +{ + public string? Title { get; init; } +} diff --git a/EnvelopeGenerator.GeneratorAPI/Models/TFARegParams.cs b/EnvelopeGenerator.GeneratorAPI/Models/TFARegParams.cs new file mode 100644 index 00000000..58073e24 --- /dev/null +++ b/EnvelopeGenerator.GeneratorAPI/Models/TFARegParams.cs @@ -0,0 +1,17 @@ +namespace EnvelopeGenerator.GeneratorAPI.Models; + +/// +/// Represents the parameters for two-factor authentication (2FA) registration. +/// +public class TFARegParams +{ + /// + /// The maximum allowed time for completing the registration process. + /// + public TimeSpan TimeLimit { get; init; } = new(0, 30, 0); + + /// + /// The deadline for registration, calculated as the current time plus the . + /// + public DateTime Deadline => DateTime.Now.AddTicks(TimeLimit.Ticks); +} \ No newline at end of file