コード例 #1
0
        /// <summary>
        /// Updates the product category mapping
        /// </summary>
        /// <param name="ProductCategoryID">Product category mapping  identifier</param>
        /// <param name="ProductID">Product identifier</param>
        /// <param name="CategoryID">Category identifier</param>
        /// <param name="IsFeaturedProduct">A value indicating whether the product is featured</param>
        /// <param name="DisplayOrder">The display order</param>
        /// <returns>Product category mapping </returns>
        public static ProductCategory UpdateProductCategory(int ProductCategoryID, int ProductID, int CategoryID,
                                                            bool IsFeaturedProduct, int DisplayOrder)
        {
            DBProductCategory dbItem = DBProviderManager <DBCategoryProvider> .Provider.UpdateProductCategory(ProductCategoryID, ProductID, CategoryID,
                                                                                                              IsFeaturedProduct, DisplayOrder);

            ProductCategory productCategory = DBMapping(dbItem);

            if (CategoryManager.CategoriesCacheEnabled || CategoryManager.MappingsCacheEnabled)
            {
                NopCache.RemoveByPattern(CATEGORIES_PATTERN_KEY);
                NopCache.RemoveByPattern(PRODUCTCATEGORIES_PATTERN_KEY);
            }
            return(productCategory);
        }
コード例 #2
0
        private static ProductCategory DBMapping(DBProductCategory dbItem)
        {
            if (dbItem == null)
            {
                return(null);
            }

            var item = new ProductCategory();

            item.ProductCategoryId = dbItem.ProductCategoryId;
            item.ProductId         = dbItem.ProductId;
            item.CategoryId        = dbItem.CategoryId;
            item.IsFeaturedProduct = dbItem.IsFeaturedProduct;
            item.DisplayOrder      = dbItem.DisplayOrder;

            return(item);
        }
コード例 #3
0
        /// <summary>
        /// Gets a product category mapping
        /// </summary>
        /// <param name="ProductCategoryID">Product category mapping identifier</param>
        /// <returns>Product category mapping</returns>
        public static ProductCategory GetProductCategoryByID(int ProductCategoryID)
        {
            string key  = string.Format(PRODUCTCATEGORIES_BY_ID_KEY, ProductCategoryID);
            object obj2 = NopCache.Get(key);

            if (CategoryManager.MappingsCacheEnabled && (obj2 != null))
            {
                return((ProductCategory)obj2);
            }

            DBProductCategory dbItem = DBProviderManager <DBCategoryProvider> .Provider.GetProductCategoryByID(ProductCategoryID);

            ProductCategory productCategory = DBMapping(dbItem);

            if (CategoryManager.MappingsCacheEnabled)
            {
                NopCache.Max(key, productCategory);
            }
            return(productCategory);
        }