Files
Budgeteer/BudgetApp/Data/Account.cs
T
2026-03-01 18:17:42 +00:00

40 lines
1.2 KiB
C#

using System.ComponentModel.DataAnnotations;
namespace BudgetApp.Data;
public class Account
{
public int Id { get; set; }
[Required, MaxLength(100)]
public string Name { get; set; } = string.Empty;
public decimal CurrentBalance { get; set; }
[Required, MaxLength(7)]
public string Color { get; set; } = "#1b6ec2";
[Required, MaxLength(3)]
public string CurrencyCode { get; set; } = "GBP";
[Required]
public string UserId { get; set; } = string.Empty;
public ApplicationUser User { get; set; } = default!;
public List<Transaction> Transactions { get; set; } = [];
public static readonly Dictionary<string, string> CurrencySymbols = new()
{
["USD"] = "$", ["EUR"] = "€", ["GBP"] = "£", ["JPY"] = "¥",
["CAD"] = "C$", ["AUD"] = "A$", ["CHF"] = "CHF", ["CNY"] = "¥",
["INR"] = "₹", ["BRL"] = "R$", ["KRW"] = "₩", ["MXN"] = "MX$",
["SEK"] = "kr", ["NOK"] = "kr", ["DKK"] = "kr", ["NZD"] = "NZ$",
["ZAR"] = "R", ["PLN"] = "zł", ["TRY"] = "₺", ["THB"] = "฿"
};
public string GetSymbol() => CurrencySymbols.GetValueOrDefault(CurrencyCode, CurrencyCode);
public string FormatAmount(decimal amount) => $"{GetSymbol()}{amount:N2}";
}