bank account refactor

This commit is contained in:
hydrant
2020-03-15 21:33:04 +01:00
parent 75e26b8e8a
commit 92c054c90c
30 changed files with 2088 additions and 300 deletions

View File

@@ -4,11 +4,12 @@ using ReallifeGamemode.Database;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
using System;
using System.Linq;
namespace ReallifeGamemode.Server.Business
{
public abstract class BusinessBase : IBankAccountOwner
public abstract class BusinessBase : BankAccountHolder<BusinessBankAccount>, IBankAccountOwner
{
private TextLabel _informationLabel;
private ColShape _colShape;
@@ -23,6 +24,34 @@ namespace ReallifeGamemode.Server.Business
public abstract Vector3 Position { get; }
public override BusinessBankAccount BankAccount
{
get
{
using (var dbContext = new DatabaseContext())
{
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).FirstOrDefault();
}
}
set => throw new NotImplementedException();
}
public override int? BankAccountId
{
get
{
using (var dbContext = new DatabaseContext())
{
return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).Select(b => b.Id).FirstOrDefault();
}
}
set => throw new NotImplementedException();
}
public override string BankAccountName => Name;
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
{
if (databaseContext == null)
@@ -110,8 +139,8 @@ namespace ReallifeGamemode.Server.Business
{
if (client.IsInVehicle || !client.IsLoggedIn()) return;
client.TriggerEvent("SERVER:Business_ShowMenuHelp");
SendBusinessDataToPlayer(client);
client.TriggerEvent("SERVER:Business_ShowMenuHelp");
}
public void SendBusinessDataToPlayer(Player player)