Add pick method
This commit is contained in:
parent
f4cdf5c9c6
commit
09e5b671c8
@ -122,7 +122,7 @@ namespace ChaosBot.Database
|
|||||||
string order = null;
|
string order = null;
|
||||||
if (orderByKey != null)
|
if (orderByKey != null)
|
||||||
{
|
{
|
||||||
order = $"ORDER BY ${orderByKey}";
|
order = $"ORDER BY {orderByKey}";
|
||||||
}
|
}
|
||||||
|
|
||||||
string query = $"SELECT {selectColumns} FROM {table} {filter} {order}";
|
string query = $"SELECT {selectColumns} FROM {table} {filter} {order}";
|
||||||
|
|||||||
@ -65,6 +65,17 @@ namespace ChaosBot.Database.Repository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Raffle PickRandom()
|
||||||
|
{
|
||||||
|
DataTable dataTable = Controller.SelectQuery(Table, "*", orderByKey: "RANDOM()");
|
||||||
|
|
||||||
|
if (dataTable.Rows.Count == 0) return null;
|
||||||
|
DataRow row = dataTable.Rows[0];
|
||||||
|
int idFetch = Convert.ToInt32((long)row["id"]);
|
||||||
|
string userIdFetch = row["userId"].ToString();
|
||||||
|
return new Raffle(idFetch, userIdFetch);
|
||||||
|
}
|
||||||
|
|
||||||
// public static void delete()
|
// public static void delete()
|
||||||
// {
|
// {
|
||||||
//
|
//
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user