Account constructor with int calling other constructor

This commit is contained in:
2021-09-17 10:46:39 -04:00
parent 4eaf226349
commit 558c02ac02
2 changed files with 6 additions and 7 deletions

View File

@ -19,8 +19,7 @@ namespace NightmareCoreWeb2
public List<Character> Characters { get; set; } public List<Character> Characters { get; set; }
public List<AccountAccess> Access { get; set; } public List<AccountAccess> Access { get; set; }
public Account(int id)
public static Account AccountByID(int id)
{ {
MySqlConnection conn = new MySqlConnection(Program.connStr); MySqlConnection conn = new MySqlConnection(Program.connStr);
@ -33,7 +32,7 @@ namespace NightmareCoreWeb2
{ {
try try
{ {
return new Account(rdr.GetString(0)); new Account(rdr.GetString(0));
} }
catch (Exception e) catch (Exception e)
@ -41,9 +40,9 @@ namespace NightmareCoreWeb2
Console.WriteLine(e); Console.WriteLine(e);
} }
} }
return null;
} }
public Account(string username) public Account(string username)
{ {
MySqlConnection conn = new MySqlConnection(Program.connStr); MySqlConnection conn = new MySqlConnection(Program.connStr);
@ -115,7 +114,7 @@ namespace NightmareCoreWeb2
Console.WriteLine(e); Console.WriteLine(e);
} }
} }
foreach (var access in this.Access) foreach (var access in this.Access)
{ {
if (access.RealmID == -1 && access.RealmID >= 1) if (access.RealmID == -1 && access.RealmID >= 1)
{ {

View File

@ -66,11 +66,11 @@ namespace NightmareCoreWeb2
this.LastModifiedTime = DateTimeOffset.FromUnixTimeSeconds(rdr.GetInt32(3)).UtcDateTime; this.LastModifiedTime = DateTimeOffset.FromUnixTimeSeconds(rdr.GetInt32(3)).UtcDateTime;
if (rdr.GetInt32(4) != 0) if (rdr.GetInt32(4) != 0)
{ {
this.ClosedBy = Account.AccountByID(rdr.GetInt32(4)); this.ClosedBy = new Account(rdr.GetInt32(4));
} }
if (rdr.GetInt32(5) != 0) if (rdr.GetInt32(5) != 0)
{ {
this.AssignedTo = Account.AccountByID(rdr.GetInt32(5)); this.AssignedTo = new Account(rdr.GetInt32(5));
} }
this.Description = rdr.GetString(6); this.Description = rdr.GetString(6);
} }