Exemple #1
0
        /// <summary>
        /// Gets list of user's bracket player info
        /// </summary>
        ///
        /// <param name="hashedUserID">
        /// Hashed user ID associated with user
        /// </param>
        ///
        /// <returns>
        /// List of user's bracket player info
        /// </returns>
        public List <BracketPlayer> GetBracketPlayerInfo(string hashedUserID)
        {
            var DB = new Database();

            using (MySqlConnection conn = new MySqlConnection(DB.GetConnString()))
            {
                string       selectQuery2 = string.Format("SELECT * FROM bracket_player_info WHERE hashedUserID='{0}'", hashedUserID);
                MySqlCommand selectCmd    = new MySqlCommand(selectQuery2, conn);
                conn.Open();
                using (MySqlDataReader reader0 = selectCmd.ExecuteReader())
                {
                    List <BracketPlayer> bracketPlayers = new List <BracketPlayer>();
                    while (reader0.Read())
                    {
                        BracketPlayer bracketPlayer = new BracketPlayer();
                        bracketPlayer.BracketID    = reader0.GetInt32("bracketID");
                        bracketPlayer.HashedUserID = reader0.GetString("hashedUserID");
                        bracketPlayer.RoleID       = reader0.GetInt32("roleID");
                        bracketPlayer.Placement    = reader0.GetInt32("placement");
                        bracketPlayer.Score        = reader0.GetInt32("score");
                        bracketPlayers.Add(bracketPlayer);
                    }
                    conn.Close();
                    return(bracketPlayers);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Inserts bracket player into bracket_player_info table
        /// </summary>
        ///
        /// <param name="bracketPlayer">
        /// Bracket player object to be inserted
        /// </param>
        ///
        /// <returns>
        /// Boolean indicating success or fail
        /// </returns>
        public bool InsertBracketPlayer(BracketPlayer bracketPlayer)
        {
            try
            {
                var DB = new Database();

                using (MySqlConnection conn = new MySqlConnection(DB.GetConnString()))
                {
                    using (MySqlCommand comm = conn.CreateCommand())
                    {
                        comm.CommandText = "INSERT INTO bracket_player_info VALUES(@bracketID, @hashedUserID, @roleID, @placement, @score, @claim, @status_code, @reason)";
                        comm.Parameters.AddWithValue("@bracketID", bracketPlayer.BracketID);
                        comm.Parameters.AddWithValue("@hashedUserID", bracketPlayer.HashedUserID);
                        comm.Parameters.AddWithValue("@roleID", bracketPlayer.RoleID);
                        comm.Parameters.AddWithValue("@placement", bracketPlayer.Placement);
                        comm.Parameters.AddWithValue("@score", bracketPlayer.Score);
                        comm.Parameters.AddWithValue("@claim", bracketPlayer.Claim);
                        comm.Parameters.AddWithValue("@status_code", bracketPlayer.StatusCode);
                        comm.Parameters.AddWithValue("@reason", bracketPlayer.Reason);
                        conn.Open();
                        comm.ExecuteNonQuery();
                        conn.Close();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemple #3
0
        public int DSGetBracketClaim(int bracketID, BracketPlayer user)
        {
            // Checks to see if the passed-in email exists in the claims datastore
            int claim = 0;

            try
            {
                using (conn = new MySqlConnection(CONNECTION_STRING))
                {
                    string selectQuery = string.Format(
                        "SELECT claim FROM bracket_player_info WHERE bracketID={0} AND hashedUserID={1}",
                        bracketID, user.HashedUserID);
                    MySqlCommand selectCmd = new MySqlCommand(selectQuery, conn);

                    conn.Open();

                    using (MySqlDataReader reader = selectCmd.ExecuteReader())
                    {
                        return(claim = reader.GetInt32(6));
                    }
                }
            }
            catch (Exception)
            {
                return(claim);
            }
        }
        /// <summary>
        /// Inserts gamer into bracket
        /// </summary>
        ///
        /// <param name="gamer">
        /// Gamer object to be inserted
        /// </param>
        ///
        /// <param name="bracketID">
        /// BracketID associated with bracket, where the gamer will be inserted
        /// </param>
        ///
        /// <returns>
        /// BracketPlayer object if insertion successful; null if not
        /// </returns>
        public BracketPlayer InsertGamerToBracket(GamerInfo gamer, BracketInfo bracket)
        {
            try
            {
                DatabaseQuery databaseQuery = new DatabaseQuery();
                TournamentBracketDatabaseQuery tournamentBracketDatabaseQuery = new TournamentBracketDatabaseQuery();
                GamerInfo     tempGamer     = databaseQuery.GetGamerInfo(gamer);
                BracketPlayer bracketPlayer = new BracketPlayer();
                bracketPlayer.BracketID    = bracket.BracketID;
                bracketPlayer.HashedUserID = tempGamer.HashedUserID;
                bracketPlayer.StatusCode   = 1;
                bracketPlayer.Claim        = null;
                bracketPlayer.Reason       = null;
                bool insertionResult = tournamentBracketDatabaseQuery.InsertBracketPlayer(bracketPlayer);
                if (insertionResult)
                {
                    tournamentBracketDatabaseQuery.UpdateBracketPlayerCount(bracket.BracketID, 1);
                    return(bracketPlayer);
                }
                return(null);
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
        public void RegisterUserToBracket_Pass()
        {
            // Arrange
            var gamerInfo = new GamerInfo();
            var bracketID = 1;

            gamerInfo.GamerTag = "GamerTag1";
            var expected = new BracketPlayer(1, "LkKpHSN1+aOvzoj3ZrCXSIxasfWSZ5j1mJI5S3er3Vw=", 0, 0, 0, null, 1, null);

            // Act
            var actual = _tournamentBracketManager.RegisterGamerIntoBracket(gamerInfo, bracketID);

            // Assert
            Assert.AreEqual(expected.BracketID, actual.BracketID);
            Assert.AreEqual(expected.HashedUserID, actual.HashedUserID);
        }