diff --git a/ReallifeGamemode.Server/Finance/Economy.cs b/ReallifeGamemode.Server/Finance/Economy.cs index e4fe8704..3df8ec42 100644 --- a/ReallifeGamemode.Server/Finance/Economy.cs +++ b/ReallifeGamemode.Server/Finance/Economy.cs @@ -15,6 +15,7 @@ using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Services; +using Newtonsoft.Json; namespace ReallifeGamemode.Server.Finance { @@ -98,32 +99,45 @@ namespace ReallifeGamemode.Server.Finance public static void ReleasePayDay(Player client, Paycheck paycheck) { - + NAPI.Util.ConsoleOutput("in release payday"); if (client == null || paycheck == null) { return; } + NAPI.Util.ConsoleOutput($"client = {client.Name}, paycheck = {JsonConvert.SerializeObject(paycheck)}"); + using (var dbContext = new DatabaseContext()) { User u = client.GetUser(dbContext); + NAPI.Util.ConsoleOutput("get user"); u.BankAccount.Balance += paycheck.Amount; u.Wage = 0; u.PaydayTimer = 60; + + NAPI.Util.ConsoleOutput("set sachen"); + var rentals = dbContext.HouseRentals .Include(hR => hR.House) .ThenInclude(h => h.BankAccount) .Where(hR => hR.UserId == u.Id); + + NAPI.Util.ConsoleOutput("get rentals"); + dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1); if (rentals.Any()) { + NAPI.Util.ConsoleOutput("hat rentals"); foreach (var rental in rentals) { - rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7); + if (rental?.House?.BankAccount != null) + { + rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7); + } } }