diff --git a/src/FiscalOS.Core/Accounts/Institution.cs b/src/FiscalOS.Core/Accounts/Institution.cs new file mode 100644 index 0000000..1551df4 --- /dev/null +++ b/src/FiscalOS.Core/Accounts/Institution.cs @@ -0,0 +1,24 @@ +namespace FiscalOS.Core.Accounts; + +public sealed class Institution : Entity +{ + public Guid UserId { get; init; } + public string Name { get; init; } = string.Empty; + public InstitutionMetadata Metadata { get; init; } = null!; + + private Institution() + { + } + + public static Institution From(string name, InstitutionMetadata metadata) + { + ArgumentNullException.ThrowIfNull(name); + ArgumentNullException.ThrowIfNull(metadata); + + return new Institution() + { + Name = name, + Metadata = metadata + }; + } +} \ No newline at end of file diff --git a/src/FiscalOS.Core/Accounts/InstitutionMetadata.cs b/src/FiscalOS.Core/Accounts/InstitutionMetadata.cs new file mode 100644 index 0000000..4c03dc1 --- /dev/null +++ b/src/FiscalOS.Core/Accounts/InstitutionMetadata.cs @@ -0,0 +1,15 @@ +namespace FiscalOS.Core.Accounts; + +public abstract class InstitutionMetadata : Entity +{ + private readonly string _type; + + public string Type => _type; + + public Guid InstitutionId { get; init; } + + protected InstitutionMetadata(string type) + { + _type = type; + } +} \ No newline at end of file diff --git a/src/FiscalOS.Core/Identity/User.cs b/src/FiscalOS.Core/Identity/User.cs index fb44cb3..e20f1c6 100644 --- a/src/FiscalOS.Core/Identity/User.cs +++ b/src/FiscalOS.Core/Identity/User.cs @@ -2,15 +2,17 @@ namespace FiscalOS.Core.Identity; public sealed class User : Entity { - private readonly List _refreshTokens = []; - public string Username { get; init; } = string.Empty; public string HashedPassword { get; init; } = string.Empty; public string EncryptionKeyId { get; init; } = string.Empty; public string EncryptedDataKey { get; init; } = string.Empty; + private readonly List _refreshTokens = []; public IEnumerable RefreshTokens => _refreshTokens; + private readonly List _institutions = []; + public IEnumerable Institutions => _institutions; + private User() { } @@ -41,4 +43,11 @@ public sealed class User : Entity _refreshTokens.Add(refreshToken); } + + public void AddInstitution(Institution institution) + { + ArgumentNullException.ThrowIfNull(institution); + + _institutions.Add(institution); + } } \ No newline at end of file diff --git a/src/FiscalOS.Core/Usings.cs b/src/FiscalOS.Core/Usings.cs index 67bbe27..b04d87e 100644 --- a/src/FiscalOS.Core/Usings.cs +++ b/src/FiscalOS.Core/Usings.cs @@ -1,3 +1,4 @@ +global using FiscalOS.Core.Accounts; global using FiscalOS.Core.Data; global using FiscalOS.Core.Identity; global using FiscalOS.Core.Security; \ No newline at end of file