Ejemplo n.º 1
0
        private List<Fixture> GetFixtures()
        {
            //command.Connection = connection;
            //command.CommandType = CommandType.StoredProcedure;
            //command.CommandText = "GetFixtures";

            connection.Open();

            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                Fixture fixture = new Fixture()
                {
                    FixtureId = Convert.ToInt32(reader["FixtureId"]),
                    HTeamID = Convert.ToInt32(reader["HTeamId"]),
                    ATeamID = Convert.ToInt32(reader["ATeamId"])
                };
                fixtures.Add(fixture);
            }
            return fixtures;
        }
Ejemplo n.º 2
0
        private void GetFixtures()
        {
            DateTime time = DateTime.Now;
            int thisWeek = Convert.ToInt16(time.GetWeekOfMonth());
            /* Select all fixtures from FixtureTbl and create a class for each fixture */

            connection.Open();
            command.Connection = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "GetFixtures";

            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                Fixture fix = new Fixture()
                {
                    FixtureId = Convert.ToInt32(reader["FixtureId"]),
                    GameWeek = Convert.ToInt16(reader["GameWeek"]),
                    HTeamID = Convert.ToInt32(reader["HTeamId"]),
                    ATeamID = Convert.ToInt32(reader["ATeamId"])
                };
                tempFixtures.Add(fix);
            }

            reader.Close();
            connection.Close();

            //http://stackoverflow.com/questions/2136487/calculate-week-of-month-in-net/2136549#2136549

            foreach (Fixture fix in tempFixtures)
            {
                if (fix.GameWeek == thisWeek)
                {
                    fixtures.Add(fix);
                }
            }
        }