public void InsertGame(Game g) { insertGameCmd.Parameters.AddWithValue("@id_white", g.WhitePlayer.Id); insertGameCmd.Parameters.AddWithValue("@id_black", g.BlackPlayer.Id); insertGameCmd.Parameters.AddWithValue("@points", g.Result.ToString()); insertGameCmd.Parameters.AddWithValue("@tournament_id", g.Tournament.Id); insertGameCmd.Parameters.AddWithValue("@playedon", g.PlayedOn.ToUniversalTime()); insertGameCmd.ExecuteNonQuery(); }
public List<Game> GetGames() { List<Game> ret = new List<Game>(); for (int i = 0; i < table.RowCount; ++i) { for (int j = i + 1; j < table.RowCount; ++j) { GameResult res = GetGameResult(i, j); if (res != GameResult.Unknown) { Game g = new Game() { WhitePlayer = GetWhitePlayer(i, j), BlackPlayer = GetBlackPlayer(i, j), Result = res, PlayedOn = BeginDate, }; ret.Add(g); } } } return ret; }