Merge branch 'feature/faction-system' into develop

This commit is contained in:
Lennart Kampshoff
2018-09-28 17:52:09 +02:00
24 changed files with 720 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
using GTANetworkAPI;
using Microsoft.EntityFrameworkCore;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
using System;
@@ -8,7 +9,7 @@ using System.Text;
/**
* @overview Life of German Reallife - Client Extension (ClientExtension.cs)
* @author VegaZ, hydrant
* @author hydrant
* @copyright (c) 2008 - 2018 Life of German
*/
@@ -16,11 +17,41 @@ namespace reallife_gamemode.Server.Extensions
{
public static class ClientExtension
{
public static User GetUser(this Client client)
public static User GetUser(this Client client, DatabaseContext context = null)
{
<<<<<<< HEAD
using (DatabaseContext dbContext = new DatabaseContext())
=======
if(context == null)
>>>>>>> feature/faction-system
{
return dbContext.Users.FirstOrDefault(u => u.Name == client.Name);
using (context = new DatabaseContext())
{
return context.Users.FirstOrDefault(u => u.Name == client.Name);
}
}
else
{
return context.Users.FirstOrDefault(u => u.Name == client.Name);
}
}
public static Faction GetFaction(this Client client, DatabaseContext context = null)
{
if(context == null)
{
using(context = new DatabaseContext())
{
User u = client.GetUser();
if (u == null) return null;
return u.GetFaction();
}
}
else
{
User u = client.GetUser();
if (u == null) return null;
return u.GetFaction();
}
}