Ejemplo n.º 1
0
        private static CategoryCollection DBMapping(DBCategoryCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            var collection = new CategoryCollection();

            foreach (var dbItem in dbCollection)
            {
                var item = DBMapping(dbItem);
                collection.Add(item);
            }

            return(collection);
        }
Ejemplo n.º 2
0
        public override DBCategoryCollection GetEverythingCategories()
        {
            var       result    = new DBCategoryCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_CategoryLoadEverything");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    var item = GetCategoryFromReader(dataReader);
                    result.Add(item);
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets all categories displayed on the home page
        /// </summary>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <param name="languageId">Language identifier</param>
        /// <returns>Category collection</returns>
        public override DBCategoryCollection GetAllCategoriesDisplayedOnHomePage(bool showHidden, int languageId)
        {
            var       result    = new DBCategoryCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_CategoryLoadDisplayedOnHomePage");

            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            db.AddInParameter(dbCommand, "LanguageID", DbType.Int32, languageId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    var item = GetCategoryFromReader(dataReader);
                    result.Add(item);
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets all categories
        /// </summary>
        /// <param name="ParentCategoryID">Parent category identifier</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Category collection</returns>
        public override DBCategoryCollection GetAllCategories(int ParentCategoryID, bool showHidden)
        {
            DBCategoryCollection categoryCollection = new DBCategoryCollection();
            Database             db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand            dbCommand = db.GetStoredProcCommand("Nop_CategoryLoadAll");

            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            db.AddInParameter(dbCommand, "ParentCategoryID", DbType.Int32, ParentCategoryID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBCategory category = GetCategoryFromReader(dataReader);
                    categoryCollection.Add(category);
                }
            }

            return(categoryCollection);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets all categories
        /// </summary>
        /// <param name="ParentCategoryID">Parent category identifier</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Category collection</returns>
        public static CategoryCollection GetAllCategories(int ParentCategoryID, bool showHidden)
        {
            string key  = string.Format(CATEGORIES_ALL_KEY, showHidden, ParentCategoryID);
            object obj2 = NopCache.Get(key);

            if (CategoryManager.CategoriesCacheEnabled && (obj2 != null))
            {
                return((CategoryCollection)obj2);
            }
            DBCategoryCollection dbCollection = DBProviderManager <DBCategoryProvider> .Provider.GetAllCategories(ParentCategoryID, showHidden);

            CategoryCollection categoryCollection = DBMapping(dbCollection);

            if (CategoryManager.CategoriesCacheEnabled)
            {
                NopCache.Max(key, categoryCollection);
            }
            return(categoryCollection);
        }