Fill out all and user methods in repo

This commit is contained in:
Daniel_I_Am 2020-06-04 01:55:05 +02:00
parent c9335cad29
commit d537143ba2
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq;
using ChaosBot.Database.Entity; using ChaosBot.Database.Entity;
namespace ChaosBot.Database.Repository namespace ChaosBot.Database.Repository
@ -8,10 +10,40 @@ namespace ChaosBot.Database.Repository
{ {
private static readonly string Table = "RaffleTable"; private static readonly string Table = "RaffleTable";
// public static Raffle[] all() public static Raffle[] all()
// { {
// DataTable dataTable = Controller.SelectQuery(Table);
// }
List<Raffle> raffles = new List<Raffle>();
foreach (DataRow row in dataTable.Rows)
{
int id = Convert.ToInt32((long) row["id"]);
string userId = row["userId"].ToString();
raffles.Add(new Raffle(id, userId));
}
return raffles.ToArray();
}
public static Raffle[] selectUser(string userId)
{
Dictionary<string, object> filterDict = new Dictionary<string, object>();
filterDict.Add("userId", userId);
DataTable dataTable = Controller.SelectQuery(Table, filterColumns: filterDict);
List<Raffle> raffles = new List<Raffle>();
foreach (DataRow row in dataTable.Rows)
{
int id = Convert.ToInt32((long) row["id"]);
string userIdFetch = row["userId"].ToString();
raffles.Add(new Raffle(id, userIdFetch));
}
return raffles.ToArray();
}
public static void insert(Raffle raffle) public static void insert(Raffle raffle)
{ {