rendered paste bodydiff --git a/Trinity.Encore.AccountService/Accounts/Account.cs b/Trinity.Encore.AccountService/Accounts/Account.cs
index 0e46b1b..f395e7f 100644
--- a/Trinity.Encore.AccountService/Accounts/Account.cs
+++ b/Trinity.Encore.AccountService/Accounts/Account.cs
@@ -7,6 +7,7 @@ using Trinity.Encore.AccountService.Database;
using Trinity.Encore.Game;
using Trinity.Encore.Game.Cryptography;
using Trinity.Encore.Services.Account;
+using System.Collections.Generic;
namespace Trinity.Encore.AccountService.Accounts
{
@@ -27,9 +28,9 @@ namespace Trinity.Encore.AccountService.Accounts
{
Record.Delete();
- var ban = Ban;
- if (ban != null)
- ban.Delete();
+ var bans = Bans;
+ foreach(var b in bans)
+ b.Delete();
}
public AccountData Serialize()
@@ -190,10 +191,15 @@ namespace Trinity.Encore.AccountService.Accounts
}
}
- public AccountBan Ban
+ public AccountBan ActiveBan
{
- get { return BanManager.Instance.FindAccountBan(x => x.Account.Id == Id); }
- set { Record.Ban = value != null ? value.Record : null; }
+ get { return BanManager.Instance.FindAccountBan(x => x.Expiry > DateTime.Now && x.Account.Id == Id); }
}
+
+ public IEnumerable<AccountBan> Bans
+ {
+ get { return BanManager.Instance.FindAccountBans(x => x.Account.Id == Id); }
+ }
+
}
}
diff --git a/Trinity.Encore.AccountService/Bans/AccountBan.cs b/Trinity.Encore.AccountService/Bans/AccountBan.cs
index 524b9fe..7459c60 100644
--- a/Trinity.Encore.AccountService/Bans/AccountBan.cs
+++ b/Trinity.Encore.AccountService/Bans/AccountBan.cs
@@ -23,7 +23,6 @@ namespace Trinity.Encore.AccountService.Bans
public void Delete()
{
Record.Delete();
- Account.Ban = null;
}
public AccountBanData Serialize()
diff --git a/Trinity.Encore.AccountService/Database/AccountRecord.cs b/Trinity.Encore.AccountService/Database/AccountRecord.cs
index aff2747..af199ce 100644
--- a/Trinity.Encore.AccountService/Database/AccountRecord.cs
+++ b/Trinity.Encore.AccountService/Database/AccountRecord.cs
@@ -69,8 +69,6 @@ namespace Trinity.Encore.AccountService.Database
public virtual byte[] LastIP { get; set; }
public virtual AccountRecord Recruiter { get; set; }
-
- public virtual AccountBanRecord Ban { get; set; }
}
public sealed class AccountMapping : MappableObject<AccountRecord>
@@ -87,7 +85,6 @@ namespace Trinity.Encore.AccountService.Database
Map(c => c.LastLogin).Nullable();
Map(c => c.LastIP).Nullable();
References(x => x.Recruiter).Nullable();
- HasOne(c => c.Ban).Cascade.All();
}
}
}
diff --git a/Trinity.Encore.AccountService/Services/AccountService.cs b/Trinity.Encore.AccountService/Services/AccountService.cs
index 5b0b27a..5607adf 100644
--- a/Trinity.Encore.AccountService/Services/AccountService.cs
+++ b/Trinity.Encore.AccountService/Services/AccountService.cs
@@ -72,7 +72,7 @@ namespace Trinity.Encore.AccountService.Services
if (acc == null)
throw new ArgumentException("No account found.");
- if (acc.Ban != null)
+ if (acc.ActiveBan != null)
throw new ArgumentException("Account ban already exists.");
BanManager.Instance.PostAsync(mgr => mgr.CreateAccountBan(acc, notes, expiry));