Exemple #1
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);
     }
 }
Exemple #2
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);
        }
Exemple #3
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();
        }
        /// <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;
                }
            }
        }