public static async Task <List <revokedAccount> > GetRevokedAccounts(int sellerId) { if ((DateTime.Now - lastUpdateRevoked).TotalSeconds < 15 && !firstTime2) { return(revokedAccounts); } List <revokedAccount> accounts = new List <revokedAccount> (); await databaseManager.selectQuery($"SELECT * FROM revokedaccounts WHERE sellerId = @sellerId LIMIT 1", delegate(DbDataReader reader) { revokedAccount account = new revokedAccount(); account.id = (int)reader["id"]; account.seller = (string)reader["seller"]; account.date = (DateTime)reader["date"]; account.sellerId = (int)reader["sellerId"]; account.email = (string)reader["email"]; account.reason = (string)reader["reason"]; account.username = (string)reader["username"]; var index = revokedAccounts.FindIndex(a => a.id == account.id); if (index != -1) { revokedAccounts[index] = account; } else { revokedAccounts.Add(account); } }).addValue("@sellerId", sellerId).Execute(); lastUpdateRevoked = DateTime.Now; firstTime2 = false; return(revokedAccounts); }
public static async Task addRevokedAccount(csgoAccount account, string reason) { revokedAccount revokedAccount = new revokedAccount(); revokedAccount.sellerId = account.sellerid; revokedAccount.seller = account.seller; revokedAccount.email = account.email; revokedAccount.username = account.username; revokedAccount.date = DateTime.Now; revokedAccount.reason = reason; await databaseManager.updateQuery($"INSERT INTO revokedaccounts (sellerId, seller, username, email, reason)" + $"VALUES (@sellerId, @seller, @username, @email, @reason )") .addValue("@sellerId", account.sellerid) .addValue("@seller", account.seller) .addValue("@username", account.username) .addValue("@email", account.email) .addValue("@reason", reason) .Execute(); revokedAccounts.Add(revokedAccount); lastUpdateRevoked = DateTime.Now; }