/// <summary> /// Gets the account data via I. /// </summary> /// <returns>The account data via ID.</returns> /// <param name="id">Identifier for DB access.</param> public TableData GetAccountDataViaID(int id) { SQLiteConnection con = new SQLiteConnection(ServerConstants.DB_PATH); TableData tb = new TableData(); tb.Units = con.Query<TableUnit>("SELECT * FROM Unit WHERE Id = ?", id); tb.Buildings = con.Query<TableBuilding>("SELECT * FROM Building WHERE Id = ?", id); tb.Resources = con.Query<TableResource>("SELECT * FROM Ressources WHERE Id = ?", id); return tb; }
/// <summary> /// Gets the account data via DB login. /// </summary> /// <returns>The account data via DB login.</returns> /// <param name="account">Account for DB data.</param> /// <param name="password">Password for DB data.</param> public TableData GetAccountDataViaDBLogin(Account account, string password) { SQLiteConnection con = new SQLiteConnection(ServerConstants.DB_PATH); DBAccount dbacc = new DBAccount(con); TableData tb = new TableData(); if (dbacc.Login(account.UserName, password)) { var data = con.Query<TableAccount>("SELECT Id FROM Account WHERE UserName = ? LIMIT 1", account.UserName); tb.Id = data[0].Id; tb.Units = con.Query<TableUnit>("SELECT * FROM Unit WHERE Id = ?", tb.Id); tb.Buildings = con.Query<TableBuilding>("SELECT * FROM Building WHERE Id = ?", tb.Id); tb.Resources = con.Query<TableResource>("SELECT * FROM Ressources WHERE Id = ?", tb.Id); } return tb; }