using System; using System.Collections.Generic; using System.Data; using System.Linq; using ChaosBot.Database.Entity; namespace ChaosBot.Database.Repository { public static class RaffleRepository { private static readonly string Table = "RaffleTable"; public static Raffle[] all() { DataTable dataTable = Controller.SelectQuery(Table); List raffles = new List(); 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 filterDict = new Dictionary(); filterDict.Add("userId", userId); DataTable dataTable = Controller.SelectQuery(Table, filterColumns: filterDict); List raffles = new List(); 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) { Dictionary dict = new Dictionary(); dict.Add("userId", raffle.userId); Controller.InsertQuery(Table, dict); } public static void massInsert(Raffle raffle, int amount) { Dictionary dict = new Dictionary(); dict.Add("userId", raffle.userId); for (int i = 0; i < amount; i++) Controller.InsertQuery(Table, dict); } // public static void delete() // { // // } } }