예제 #1
0
        /// <summary>
        ///   
        /// </summary>
        /// <param name="habboId">The category ID to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static string GetCategoryNameFromCategoryId(int categoryId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@category_id"] = categoryId;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction<string>("SELECT `category_name` FROM `messenger_categories` WHERE `category_id` = @category_id", parameters, connection);
        }
예제 #2
0
        /// <summary>
        ///   
        /// </summary>
        /// <param name="habboId">The Habbo ID to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static IEnumerable<int> GetCategoryIdsFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@habbo_id"] = habboId;

            List<int> categoryIds = new List<int>();

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCommand("SELECT `category_id` FROM `messenger_habbo_categories` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters))
                {
                    while (reader.Read())
                    {
                        categoryIds.Add((int)reader["category_id"]);
                    }

                    return categoryIds;
                }
            }
        }
예제 #3
0
 public bool HelperSetAction(string query, Dictionary <string, object> parameters, WrappedMySqlConnection connection = null)
 {
     using (connection = connection ?? GetConnection())
     {
         // Get the value from the database and return it.
         return(connection.GetCommand(query).ExecuteNonQuery(parameters) > 0);
     }
 }
예제 #4
0
        public T HelperGetAction <T>(string query, Dictionary <string, object> parameters, WrappedMySqlConnection connection = null)
        {
            dynamic returnValue;

            using (connection = connection ?? GetConnection())
            {
                returnValue = connection.GetCommand(query).ExecuteScalar(parameters);
            }

            if (returnValue != null)
            {
                return((T)returnValue);
            }
            throw new NoResultsException();
        }
예제 #5
0
        public bool HelperExistsAction(string query, Dictionary <string, object> parameters, WrappedMySqlConnection connection = null)
        {
            object returnValue;

            using (connection = connection ?? GetConnection())
            {
                returnValue = connection.GetCommand(query).ExecuteScalar(parameters);
            }
            return(returnValue != null);
        }