This commit is contained in:
2023-07-23 20:27:23 +03:00
parent d0cdaa85b6
commit 96eca795ab
62 changed files with 2934 additions and 847 deletions
+11
View File
@@ -5,6 +5,7 @@ using Data.Models.Currencies;
using Data.Models.Items;
using Microsoft.EntityFrameworkCore;
using Data.Models.Users;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
public enum AppDbContextProvidersEnum
{
@@ -144,6 +145,11 @@ public class AppDbContext : DbContext
.WithMany(x => x.Accounts)
.HasForeignKey(x => x.CurrencyGlobalId);
modelBuilder.Entity<Account>()
.HasOne(x => x.Owner)
.WithMany(x => x.Accounts)
.HasForeignKey(x => x.OwnerId);
modelBuilder.Entity<AccountAccess>()
.HasOne(x => x.Account)
.WithMany(x => x.AccessRights)
@@ -173,6 +179,11 @@ public class AppDbContext : DbContext
.HasOne(x => x.Category)
.WithMany(x => x.Accounts)
.HasForeignKey(x => x.CategoryId);
modelBuilder
.Entity<AccountAccess>()
.Property(d => d.Type)
.HasConversion(new EnumToStringConverter<AccountAccessTypeEnum>());
}
private void MotionsCreating(ModelBuilder modelBuilder)
+9 -9
View File
@@ -32,15 +32,15 @@ public class RepositoryInitializer
// CurrencyGlobals
var predefinedCurrencyGlobals = new List<CurrencyGlobal>()
{
new() { Id = "UAH", DefaultQuantity = 1, Symbol = "₴", Name = "Ukrainian hryvnias" },
new() { Id = "USD", DefaultQuantity = 1, Symbol = "$", Name = "US Dollar" },
new() { Id = "EUR", DefaultQuantity = 1, Symbol = "€", Name = "Euros" },
new() { Id = "GBP", DefaultQuantity = 1, Symbol = "£", Name = "British pounds sterling" },
new() { Id = "RUB", DefaultQuantity = 10, Symbol = "₽", Name = "Russia Ruble" },
new() { Id = "BTC", DefaultQuantity = 10, Symbol = "btc", Name = "Bitcoin" },
new() { Id = "ETH", DefaultQuantity = 10, Symbol = "eth", Name = "Ethereum" },
new() { Id = "TON", DefaultQuantity = 10, Symbol = "ton", Name = "TON" },
new() { Id = "OTHER", DefaultQuantity = 1, Symbol = "", Name = "Other" },
new() { Id = CurrencyGlobalIdEnum.UAH.ToString(), DefaultQuantity = 1, Symbol = "₴", Name = "Ukrainian hryvnias" },
new() { Id = CurrencyGlobalIdEnum.USD.ToString(), DefaultQuantity = 1, Symbol = "$", Name = "US Dollar" },
new() { Id = CurrencyGlobalIdEnum.EUR.ToString(), DefaultQuantity = 1, Symbol = "€", Name = "Euros" },
new() { Id = CurrencyGlobalIdEnum.GBP.ToString(), DefaultQuantity = 1, Symbol = "£", Name = "British pounds sterling" },
new() { Id = CurrencyGlobalIdEnum.RUB.ToString(), DefaultQuantity = 10, Symbol = "₽", Name = "Russia Ruble" },
new() { Id = CurrencyGlobalIdEnum.BTC.ToString(), DefaultQuantity = 10, Symbol = "btc", Name = "Bitcoin" },
new() { Id = CurrencyGlobalIdEnum.ETH.ToString(), DefaultQuantity = 10, Symbol = "eth", Name = "Ethereum" },
new() { Id = CurrencyGlobalIdEnum.TON.ToString(), DefaultQuantity = 10, Symbol = "ton", Name = "TON" },
new() { Id = CurrencyGlobalIdEnum.OTHER.ToString(), DefaultQuantity = 1, Symbol = "", Name = "Other" },
};
var currencyGlobals = dbContext.CurrencyGlobals.ToList();