示例#1
0
        /// <summary>
        /// Search for a player
        /// Returns if a player is found
        /// </summary>
        /// <param name="username">Username of the player</param>
        /// <returns>Returns if a player is found with the usernames</returns>
        static bool PlayerExist(string username)
        {
            string sql = String.Format("SELECT * FROM [dbo].[{0}] WHERE Username = '******'"
                                       , tableName
                                       , username);
            Dictionary <string, object> results = new Dictionary <string, object>();

            if (DBEndPoint.GetSingleRowSqlSearch(sql, results))
            {
                return(true);
            }
            return(false);
        }
示例#2
0
        /// <summary>
        /// Search for a player
        /// Returns null if no player is found
        /// </summary>
        /// <param name="username">Username of the player</param>
        /// <param name="hashedPassword">Hashed password of the player </param>
        /// <returns>The player profile, null if none were found</returns>
        public static DBProfile_Login GetPlayer(string username, string hashedPassword)
        {
            string sql = String.Format("SELECT * FROM [dbo].[{0}] WHERE Username = '******' and Password = '******'"
                                       , tableName
                                       , username
                                       , hashedPassword);
            Dictionary <string, object> results = new Dictionary <string, object>();

            if (DBEndPoint.GetSingleRowSqlSearch(sql, results))
            {
                DBProfile_Login profile;
                profile = new DBProfile_Login((int)results["Id"], (string)results["Username"]);
                return(profile);
            }
            return(null);
        }
示例#3
0
        /// <summary>
        /// Returns the profile of a player
        /// </summary>
        /// <param name="username"></param>
        /// <param name="hashedPassword"></param>
        /// <returns>Returns the profile of a player, returns null if none were found</returns>
        public static DBProfile_Stats GetPlayer(string username, string hashedPassword)
        {
            var player = DBLogin.GetPlayer(username, hashedPassword);

            if (player == null)
            {
                return(null);
            }
            string sql = String.Format("SELECT * FROM [dbo].[{0}] WHERE Id = {1}"
                                       , tableName
                                       , player.id);
            Dictionary <string, object> results = new Dictionary <string, object>();

            if (DBEndPoint.GetSingleRowSqlSearch(sql, results))
            {
                DBProfile_Stats profile;
                profile = new DBProfile_Stats((int)results["Wins"], (int)results["Losses"], (int)results["Kills"], (int)results["Deaths"]);
                return(profile);
            }
            return(null);
        }