/// <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 List <BracketCompetitor> GetCompetitorListByBracketID(int bracketID)
        {
            TournamentBracketDatabaseQuery tournamentBracketDatabaseQuery = new TournamentBracketDatabaseQuery();
            var listOfCompetitors = tournamentBracketDatabaseQuery.GetCompetitorListByBracketID(bracketID);

            return(listOfCompetitors);
        }
        public bool UpdateBracketStanding(int bracketID, BracketCompetitor bracketCompetitor)
        {
            TournamentBracketDatabaseQuery tournamentBracketDatabaseQuery = new TournamentBracketDatabaseQuery();
            bool result = tournamentBracketDatabaseQuery.UpdateBracketStandings(bracketID, bracketCompetitor);

            return(result);
        }
 /// <summary>
 /// Unregisters gamer from bracket
 /// </summary>
 ///
 /// <param name="systemID">
 /// System ID associated with user
 /// </param>
 ///
 /// <param name="bracketID">
 /// Bracket ID associated with bracket
 /// </param>
 ///
 /// <returns>
 /// Boolean indicated success or fail in unregistration
 /// </returns>
 public bool UnregisterGamerFromBracket(int systemID, int bracketID)
 {
     /*
      * Status codes
      *
      * 2 - bracket is in progress
      * 1 - bracket not in progress and has already completed
      * 0 - bracket not in progress and has not begun
      */
     try
     {
         DatabaseQuery databaseQuery = new DatabaseQuery();
         TournamentBracketDatabaseQuery tournamentBracketDatabaseQuery = new TournamentBracketDatabaseQuery();
         string      hashedUserID = databaseQuery.GetHashedUserID(systemID);
         BracketInfo bracket      = tournamentBracketDatabaseQuery.GetBracketInfo(bracketID);
         if (bracket.StatusCode == 2)
         {
             return(tournamentBracketDatabaseQuery.DisqualifyGamerFromBracket(bracketID, hashedUserID));
         }
         else if (bracket.StatusCode == 0)
         {
             bool removeResult = tournamentBracketDatabaseQuery.RemoveGamerFromBracket(hashedUserID, bracketID);
             bool updateResult = tournamentBracketDatabaseQuery.UpdateBracketPlayerCount(bracketID, 0);
             if (removeResult && updateResult)
             {
                 return(true);
             }
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>
        /// Gets bracket player info by user's email
        /// </summary>
        ///
        /// <param name="email">
        /// Email associated with user
        /// </param>
        ///
        /// <returns>
        /// List of user's BracketPlayer info
        /// </returns>
        public List <BracketPlayer> GetBracketPlayerInfo(string email)
        {
            DatabaseQuery databaseQuery = new DatabaseQuery();
            TournamentBracketDatabaseQuery tournamentBracketDatabaseQuery = new TournamentBracketDatabaseQuery();
            User user = databaseQuery.GetUserInfo(email);

            if (user != null)
            {
                string hashedUserID = databaseQuery.GetHashedUserID(user.SystemID);
                List <BracketPlayer> bracketPlayers = tournamentBracketDatabaseQuery.GetBracketPlayerInfo(hashedUserID);
                return(bracketPlayers);
            }
            return(null);
        }
        /// <summary>
        /// Gets a specific bracket by its ID
        /// </summary>
        ///
        /// <param name="bracketID">
        /// Bracket ID to be used to fetch bracket objectr
        /// </param>
        ///
        /// <returns>
        /// Bracket object associated with bracket ID
        /// </returns>
        public BracketInfo GetBracketByID(int bracketID)
        {
            bool bracketStatus = CheckBracketExistenceByID(bracketID);

            if (!bracketStatus)
            {
                return(null);
            }
            else
            {
                TournamentBracketDatabaseQuery tournamentBracketDatabaseQuery = new TournamentBracketDatabaseQuery();
                BracketInfo bracket = tournamentBracketDatabaseQuery.GetBracketInfo(bracketID);
                return(bracket);
            }
        }
        /// <summary>
        /// Returns all brackets stored in the database
        /// </summary>
        ///
        /// <returns>
        /// All brackets stored in the database
        /// </returns>
        public List <BracketInfo> GetAllBrackets()
        {
            TournamentBracketDatabaseQuery tournamentBracketDatabaseQuery = new TournamentBracketDatabaseQuery();

            return(tournamentBracketDatabaseQuery.GetAllBrackets());
        }