Fixed EF error, edit commands, fix faction broadcast

This commit is contained in:
Lennart Kampshoff
2018-09-23 15:59:40 +02:00
parent 22df6c6a2e
commit f91ef8960c
6 changed files with 82 additions and 27 deletions

View File

@@ -21,9 +21,9 @@ namespace reallife_gamemode.Server.Extensions
{
if(context == null)
{
using (DatabaseContext dbContext = new DatabaseContext())
using (context = new DatabaseContext())
{
return dbContext.Users.FirstOrDefault(u => u.Name == client.Name);
return context.Users.FirstOrDefault(u => u.Name == client.Name);
}
}
else
@@ -36,14 +36,18 @@ namespace reallife_gamemode.Server.Extensions
{
if(context == null)
{
using (DatabaseContext dbContext = new DatabaseContext())
using(context = new DatabaseContext())
{
return dbContext.Factions.Find(client.GetUser(context).Faction);
User u = client.GetUser();
if (u == null) return null;
return context.Factions.FirstOrDefault(f => f.Id == u.FactionId);
}
}
else
{
return context.Factions.Find(client.GetUser(context).Faction);
User u = client.GetUser();
if (u == null) return null;
return context.Factions.FirstOrDefault(f => f.Id == u.FactionId);
}
}
}