Merge develop into feature/inventory-system
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -16,7 +17,7 @@ using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class User
|
||||
public class User : IBankAccountOwner
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
@@ -28,8 +29,8 @@ namespace reallife_gamemode.Server.Entities
|
||||
[StringLength(64)]
|
||||
public string Password { get; set; }
|
||||
public int LogUserId { get; set; }
|
||||
[Timestamp]
|
||||
public byte[] RegistrationDate { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public DateTime RegistrationDate { get; set; }
|
||||
|
||||
[EmailAddress]
|
||||
[StringLength(64)]
|
||||
@@ -122,12 +123,11 @@ namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
using (var unbanUser = new DatabaseContext())
|
||||
{
|
||||
var targetUser = unbanUser.Bans.FirstOrDefault(u => u.Id == BanId);
|
||||
unbanUser.Bans.Remove(targetUser);
|
||||
User user = admin.GetUser();
|
||||
var targetUser = unbanUser.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
targetUser.BanId = null;
|
||||
unbanUser.SaveChanges();
|
||||
}
|
||||
admin.SendChatMessage(this.Name + " wurde entbannt.");
|
||||
//TODO ***Admin Info: {ADMIN-NAME} hat {USER-NAME} entbannt.
|
||||
}
|
||||
|
||||
public List<UserItem> GetItems()
|
||||
@@ -138,5 +138,20 @@ namespace reallife_gamemode.Server.Entities
|
||||
}
|
||||
}
|
||||
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user