using GTANetworkAPI;
using Microsoft.EntityFrameworkCore;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;

namespace ReallifeGamemode.Server.Util
{
  class FactionHelper
  {
    public static void CheckFactionBankAccounts()
    {
      NAPI.Util.ConsoleOutput("Checking faction bank accounts...");
      using (var dbContext = new DatabaseContext())
      {
        foreach (Faction faction in dbContext.Factions.Include(f => f.BankAccount))
        {
          if (faction.BankAccount == null)
          {
            NAPI.Util.ConsoleOutput("Adding bank account for faction: " + faction.Name);
            faction.BankAccount = new FactionBankAccount()
            {
              Balance = 0,
              Bic = "",
              Iban = "",
              Active = true
            };
          }
        }
        dbContext.SaveChanges();
      }
    }
  }
}
