mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-25 14:40:31 -05:00
Added unban "penalty"
permbans ->MaxValue for consistency Existing alias needs to be FirstOrDefault
This commit is contained in:
@ -27,7 +27,7 @@ namespace SharedLibrary.Services
|
||||
.ToListAsync();
|
||||
|
||||
// see if they have a matching IP + Name but new NetworkId
|
||||
var existingAlias = aliases.SingleOrDefault(a => a.Name == entity.Name);
|
||||
var existingAlias = aliases.FirstOrDefault(a => a.Name == entity.Name);
|
||||
// if existing alias matches link them
|
||||
EFAliasLink aliasLink = existingAlias?.Link;
|
||||
// if no exact matches find the first IP that matches
|
||||
|
@ -18,14 +18,16 @@ namespace SharedLibrary.Services
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
entity.Offender = context.Clients.First(e => e.ClientId == entity.Offender.ClientId);
|
||||
entity.Punisher = context.Clients.First(e => e.ClientId == entity.Punisher.ClientId);
|
||||
entity.Link = context.AliasLinks.First(l => l.AliasLinkId == entity.Link.AliasLinkId);
|
||||
entity.Offender = context.Clients.Single(e => e.ClientId == entity.Offender.ClientId);
|
||||
entity.Punisher = context.Clients.Single(e => e.ClientId == entity.Punisher.ClientId);
|
||||
entity.Link = context.AliasLinks.Single(l => l.AliasLinkId == entity.Link.AliasLinkId);
|
||||
|
||||
if (entity.Expires == DateTime.MaxValue)
|
||||
entity.Expires = DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MaxValue.ToString());
|
||||
|
||||
// make bans propogate to all aliases
|
||||
if (entity.Type == Objects.Penalty.PenaltyType.Ban)
|
||||
{
|
||||
entity.Expires = DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MaxValue.ToString());
|
||||
await context.Clients
|
||||
.Where(c => c.AliasLinkId == entity.Link.AliasLinkId)
|
||||
.ForEachAsync(c => c.Level = Objects.Player.Permission.Banned);
|
||||
|
Reference in New Issue
Block a user