From 3ea07adf46db87848824871ab01dc9149f49f776 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Fri, 17 Sep 2021 10:37:42 -0400 Subject: [PATCH] Move IsGM to Account class --- Account.cs | 8 ++++++++ Pages/Account.cshtml | 2 +- Pages/Account.cshtml.cs | 10 ++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Account.cs b/Account.cs index e15de46..daee635 100644 --- a/Account.cs +++ b/Account.cs @@ -10,6 +10,7 @@ namespace NightmareCoreWeb2 public class Account { public UInt32 Id { get; set; } + public bool IsGM {get; set;} public string Username { get; set; } public string Email { get; set; } public string LastIP { get; set; } @@ -113,6 +114,13 @@ namespace NightmareCoreWeb2 { Console.WriteLine(e); } + } + foreach (var access in this.Access) + { + if (access.RealmID == -1 && access.RealmID >= 1) + { + this.IsGM = true; + } } rdr.Close(); diff --git a/Pages/Account.cshtml b/Pages/Account.cshtml index b3bd6ef..828c5d4 100644 --- a/Pages/Account.cshtml +++ b/Pages/Account.cshtml @@ -55,7 +55,7 @@
- @if (Model.IsGM) + @if (Model.UserAccount.IsGM) { @foreach (var ticket in Model.Tickets) { diff --git a/Pages/Account.cshtml.cs b/Pages/Account.cshtml.cs index 1e33e6c..0de24c5 100644 --- a/Pages/Account.cshtml.cs +++ b/Pages/Account.cshtml.cs @@ -14,7 +14,6 @@ namespace NightmareCoreWeb2.Pages public string CharacterListType { get; set; } public string AuthToken { get; set; } public string Username { get; set; } - public bool IsGM { get; set; } public bool IsAuthenticated = false; public Account UserAccount { get; set; } public List OnlineCharacters = new List(); @@ -81,13 +80,8 @@ namespace NightmareCoreWeb2.Pages Account a = new Account(Username); UserAccount = a; OnlineCharacters = a.Characters; - foreach (var access in a.Access) - { - if (access.RealmID == -1 && access.RealmID >= 1) - { - this.IsGM = true; - this.Tickets = GMTicket.GetAllTickets(); - } + if (a.IsGM) { + this.Tickets = GMTicket.GetAllTickets(); } ViewData["Title"] = a.Username; CharacterListType = $"{a.Username}'s Characters";