Пример #1
0
        /// <summary>
        /// Gets a product category mapping collection
        /// </summary>
        /// <param name="ProductID">Product identifier</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Product category mapping collection</returns>
        public override DBProductCategoryCollection GetProductCategoriesByProductID(int ProductID, bool showHidden)
        {
            DBProductCategoryCollection productCategoryCollection = new DBProductCategoryCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_Product_Category_MappingLoadByProductID");

            db.AddInParameter(dbCommand, "ProductID", DbType.Int32, ProductID);
            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBProductCategory productCategory = GetProductCategoryFromReader(dataReader);
                    productCategoryCollection.Add(productCategory);
                }
            }

            return(productCategoryCollection);
        }
Пример #2
0
        /// <summary>
        /// Gets product category mapping collection
        /// </summary>
        /// <param name="categoryId">Category identifier</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Product a category mapping collection</returns>
        public override DBProductCategoryCollection GetProductCategoriesByCategoryId(int categoryId, bool showHidden)
        {
            var       result    = new DBProductCategoryCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_Product_Category_MappingLoadByCategoryID");

            db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, categoryId);
            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    var item = GetProductCategoryFromReader(dataReader);
                    result.Add(item);
                }
            }

            return(result);
        }