Exemplo n.º 1
0
        private TeamStat GetGameStat(int gameId, int teamId)
        {
            SqliteCommand cmd = DB.DBConnection.Connection.CreateCommand();

            cmd.CommandText = $"SELECT * FROM game_stat WHERE game_id = {gameId} AND team_id = {teamId}";

            SqliteDataReader reader = null;

            try
            {
                reader = cmd.ExecuteReader();
            }
            catch (SqliteException ex)
            {
                Console.WriteLine(ex.Message);
            }

            TeamStat stat = new TeamStat();

            while (reader.Read())
            {
                stat.Shots      = Convert.ToInt32(reader["shots"].ToString());
                stat.ShotsIn    = Convert.ToInt32(reader["shots_in"].ToString());
                stat.Faceoff    = Convert.ToInt32(reader["faceoff"].ToString());
                stat.Hits       = Convert.ToInt32(reader["hits"].ToString());
                stat.BlockShots = Convert.ToInt32(reader["block_shots"].ToString());
                stat.Penalty    = Convert.ToInt32(reader["penalty"].ToString());
            }

            return(stat);
        }
Exemplo n.º 2
0
        public Game()
        {
            Actions = new List <GameAction>();
            Goal    = new List <Goal>();

            Score = new Tuple <int, int>(0, 0);

            Stat1 = new TeamStat();
            Stat2 = new TeamStat();
        }
Exemplo n.º 3
0
        public void AddGameStat(int gameId, TeamStat stat, int teamId)
        {
            SqliteCommand cmd = DB.DBConnection.Connection.CreateCommand();

            cmd.CommandText = string.Format(
                "INSERT INTO game_stat " +
                "(game_id, team_id, shots, shots_in,faceoff, hits, block_shots, penalty) " +
                "VALUES({0},{1}, {2}, {3}, {4},{5}, {6},{7})",
                gameId, teamId, stat.Shots, stat.ShotsIn, stat.Faceoff, stat.Hits, stat.BlockShots, stat.Penalty);

            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (SqliteException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }