public List <Lottery> GetLotteries() { List <Lottery> lotterySetupArr = new List <Lottery>(); using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource()) using (OleDbCommand command = new OleDbCommand()) { command.CommandType = CommandType.Text; command.CommandText = "SELECT * FROM lottery WHERE active = true;"; command.Connection = conn; conn.Open(); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { LotterySetup lotterySetup = new LotterySetup(); lotterySetup.GameCode = ClassReflectionUtil.FindGameMode(int.Parse(reader["game_cd"].ToString())); lotterySetup.Description = reader["description"].ToString(); lotterySetup.PricePerBet = double.Parse(reader["price_per_bet"].ToString()); lotterySetup.WebScrapeGameCode = int.Parse(reader["web_scrape_code"].ToString()); lotterySetupArr.Add(lotterySetup); } } } return(lotterySetupArr); }
public Lottery GetLottery(GameMode gameCode) { LotterySetup lotterySetup = new LotterySetup(); using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource()) using (OleDbCommand command = new OleDbCommand()) { command.CommandType = CommandType.Text; command.CommandText = "SELECT * FROM lottery WHERE game_cd = @game_cd AND active = true;"; command.Parameters.AddWithValue("@game_cd", gameCode); command.Connection = conn; conn.Open(); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { lotterySetup.GameCode = gameCode; lotterySetup.Description = reader["description"].ToString(); lotterySetup.PricePerBet = double.Parse(reader["price_per_bet"].ToString()); lotterySetup.WebScrapeGameCode = int.Parse(reader["web_scrape_code"].ToString()); } } } return(lotterySetup); }