Almost finished base business system backend

This commit is contained in:
hydrant
2018-11-22 22:19:34 +01:00
parent a72d65eb18
commit 054e9159e1
5 changed files with 87 additions and 15 deletions

View File

@@ -56,16 +56,22 @@ namespace reallife_gamemode.Server.Business
public void Update()
{
User owner = GetOwner();
string infoText = Name + "\n" + "Besitzer: " + (owner == null ? "Niemand" : owner.Name) + "\nKasse: " + (GetBankAccount()?.Balance ?? 0);
string infoText = Name + "\n" + "Besitzer: " + (owner == null ? "Niemand" : owner.Name) + "\nKasse: ~g~" + (GetBankAccount()?.Balance ?? 0) + "$";
_informationLabel.Text = infoText;
}
public User GetOwner()
public User GetOwner(DatabaseContext dbContext = null)
{
using (var dbContext = new DatabaseContext())
if(dbContext == null)
{
User user = dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
return user;
using (dbContext = new DatabaseContext())
{
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
}
}
else
{
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
}
}