コード例 #1
0
ファイル: IYFDData.cs プロジェクト: dtlydon/iyfd
        public bool GenerateNextRoundMatchups(Round round)
        {
            double tempSeeds;
            int numOfSeeds;

            tempSeeds = 16 / (Math.Pow(2, round.Name - 1));

            if (!int.TryParse(tempSeeds.ToString(), out numOfSeeds))
                return false;

            List<int> regionIds = new List<int>();
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["IYFD"].ToString()))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand("dbo.GetAllRegions", connection))
                {
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            regionIds.Add(Convert.ToInt32(reader["id"]));
                        }
                    }
                }
                foreach (int j in regionIds)
                {
                    for (int i = 1; i <= numOfSeeds / 2; i++)
                    {
                        using (SqlCommand cmd = new SqlCommand("dbo.GenerateMatchup", connection))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.AddWithValue("@regionID", j);
                            cmd.Parameters.AddWithValue("@seed", i);
                            cmd.Parameters.AddWithValue("@numOfSeed", numOfSeeds);
                            cmd.Parameters.AddWithValue("@roundId", round.ID);
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }

            return true;
        }
コード例 #2
0
ファイル: IYFDData.cs プロジェクト: dtlydon/iyfd
        public bool UpsertRound(Round round)
        {
            int rows = 0;
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["IYFD"].ToString()))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand("dbo.UpsertRound", connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    //if(team.ID != null)
                    //cmd.Parameters.AddWithValue("@ID", team.ID);
                    cmd.Parameters.AddWithValue("@round", round.Name);

                    rows = cmd.ExecuteNonQuery();
                }
            }
            return rows > 0;
        }