bank account refactor
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
|
||||
@@ -11,20 +12,18 @@ namespace ReallifeGamemode.Server.Util
|
||||
NAPI.Util.ConsoleOutput("Checking faction bank accounts...");
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (Faction faction in dbContext.Factions)
|
||||
foreach (Faction faction in dbContext.Factions.Include(f => f.BankAccount))
|
||||
{
|
||||
if (faction.GetBankAccount(dbContext) == null)
|
||||
if (faction.BankAccount == null)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Adding bank account for faction: " + faction.Name);
|
||||
FactionBankAccount factionBankAccount = new FactionBankAccount()
|
||||
faction.BankAccount = new FactionBankAccount()
|
||||
{
|
||||
Balance = 0,
|
||||
Bic = "",
|
||||
Iban = "",
|
||||
FactionId = faction.Id,
|
||||
Active = true
|
||||
};
|
||||
dbContext.FactionBankAccounts.Add(factionBankAccount);
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
|
||||
Reference in New Issue
Block a user