Automatic add business bank account, renamed sms to telephone business

This commit is contained in:
hydrant
2018-11-22 18:06:27 +01:00
parent cef42180c9
commit 74dc1db8af
3 changed files with 38 additions and 5 deletions

View File

@@ -36,12 +36,25 @@ namespace reallife_gamemode.Server.Business
public void Setup()
{
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position, 20.0f, 1.3f, 0, new Color(255, 255, 255));
if (GetBankAccount() == null)
{
NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name);
using (var dbContext = new DatabaseContext())
{
dbContext.BusinessBankAccounts.Add(new BusinessBankAccount()
{
BusinessId = Id,
Balance = 0
});
dbContext.SaveChanges();
}
}
}
public void Update()
{
//NAPI.Util.ConsoleOutput("Updating Business: " + Name);
User owner = GetOwner();
string infoText = Name + "\n" + "Besitzer: " + (owner == null ? "Niemand" : owner.Name) + "\nKasse: " + (GetBankAccount()?.Balance ?? 0);
_informationLabel.Text = infoText;
@@ -52,7 +65,6 @@ namespace reallife_gamemode.Server.Business
using (var dbContext = new DatabaseContext())
{
User user = dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
//NAPI.Util.ConsoleOutput("[" + Name + "] GetOwner: " + (user?.Name ?? "null"));
return user;
}
}