haus system auf core geändert
This commit is contained in:
19
ReallifeGamemode.Server.Core.Extensions/IntegerExtensions.cs
Normal file
19
ReallifeGamemode.Server.Core.Extensions/IntegerExtensions.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Core.Extensions
|
||||
{
|
||||
public static class IntegerExtensions
|
||||
{
|
||||
public static string ToMoneyString(this int? money)
|
||||
{
|
||||
return ToMoneyString(money ?? 0);
|
||||
}
|
||||
public static string ToMoneyString(this int money)
|
||||
{
|
||||
return "$" + string.Format(new CultureInfo("de-DE"), "{0:C0}", money).Replace("€", "").Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
@@ -10,14 +11,26 @@ namespace ReallifeGamemode.Server.Core.Extensions
|
||||
{
|
||||
public static class PlayerExtensions
|
||||
{
|
||||
public static User GetUser(this IPlayer player, DatabaseContext dbContext)
|
||||
public static User GetUser(this IPlayer player, DatabaseContext dbContext, bool bankAccount = false, bool faction = false)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return dbContext.Users.Where(u => u.Name == player.Name).FirstOrDefault();
|
||||
var user = dbContext.Users.Where(u => u.Name == player.Name);
|
||||
|
||||
if (bankAccount)
|
||||
{
|
||||
user = user.Include(u => u.BankAccount);
|
||||
}
|
||||
|
||||
if (faction)
|
||||
{
|
||||
user = user.Include(u => u.Faction);
|
||||
}
|
||||
|
||||
return user.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static AdminLevel GetAdminLevel(this IPlayer player, DatabaseContext dbContext)
|
||||
@@ -39,5 +52,7 @@ namespace ReallifeGamemode.Server.Core.Extensions
|
||||
{
|
||||
return player.GetAdminLevel(dbContext) >= level;
|
||||
}
|
||||
|
||||
public static bool IsLoggedIn(this IPlayer player) => player.GetSharedData("isLoggedIn", false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user