feat(core): add models for account
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
namespace FiscalOS.Core.Accounts;
|
||||
|
||||
public sealed class Account : Entity
|
||||
{
|
||||
public Guid UserId { get; init; }
|
||||
public Guid InstituionId { get; init; }
|
||||
public Institution Institution { get; init; } = null!;
|
||||
public string Name { get; init; } = string.Empty;
|
||||
public AccountMetadata Metadata { get; init; } = null!;
|
||||
|
||||
public static Account From(Guid institutionId, string name, AccountMetadata accountMetadata)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
InstituionId = institutionId,
|
||||
Name = name,
|
||||
Metadata = accountMetadata,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace FiscalOS.Core.Accounts;
|
||||
|
||||
public abstract class AccountMetadata : Entity
|
||||
{
|
||||
private readonly string _type;
|
||||
|
||||
public string Type => _type;
|
||||
|
||||
public Guid AccountId { get; init; }
|
||||
|
||||
protected AccountMetadata(string type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ public sealed class User : Entity
|
||||
private readonly List<Institution> _institutions = [];
|
||||
public IEnumerable<Institution> Institutions => _institutions;
|
||||
|
||||
private readonly List<Account> _accounts = [];
|
||||
public IEnumerable<Account> Accounts => _accounts;
|
||||
|
||||
private User()
|
||||
{
|
||||
}
|
||||
@@ -50,4 +53,11 @@ public sealed class User : Entity
|
||||
|
||||
_institutions.Add(institution);
|
||||
}
|
||||
|
||||
public void AddAccount(Account account)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(account, nameof(account));
|
||||
|
||||
_accounts.Add(account);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user