当前位置: 首页>>代码示例>>C#>>正文


C# ICategoryService.GetCategoryById方法代码示例

本文整理汇总了C#中ICategoryService.GetCategoryById方法的典型用法代码示例。如果您正苦于以下问题:C# ICategoryService.GetCategoryById方法的具体用法?C# ICategoryService.GetCategoryById怎么用?C# ICategoryService.GetCategoryById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICategoryService的用法示例。


在下文中一共展示了ICategoryService.GetCategoryById方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCategoryNameWithPrefix

        public static string GetCategoryNameWithPrefix(this Category category, ICategoryService categoryService, IDictionary<int, Category> mappedCategories = null)
        {
            string result = string.Empty;

            while (category != null)
            {
                if (String.IsNullOrEmpty(result))
                {
                    result = category.GetFullCategoryName();
                }
                else
                {
                    result = "--" + result;
                }

                int parentId = category.ParentCategoryId;
                if (mappedCategories == null)
                {
                    category = categoryService.GetCategoryById(parentId);
                }
                else
                {
                    category = mappedCategories.ContainsKey(parentId) ? mappedCategories[parentId] : categoryService.GetCategoryById(parentId);
                }
            }
            return result;
        }
开发者ID:omidghorbani,项目名称:SmartStoreNET,代码行数:27,代码来源:CategoryExtensions.cs

示例2: GetCategoryBreadCrumb

        public static string GetCategoryBreadCrumb(this Category category, ICategoryService categoryService, IDictionary<int, Category> mappedCategories = null)
        {
            string result = string.Empty;

            while (category != null && !category.Deleted)
            {
                // codehint: sm-edit
                if (String.IsNullOrEmpty(result))
                {
                    result = category.GetFullCategoryName();
                }
                else
                {
                    result = category.GetFullCategoryName() + " >> " + result;
                }

                int parentId = category.ParentCategoryId;
                if (mappedCategories == null)
                {
                    category = categoryService.GetCategoryById(parentId);
                }
                else
                {
                    category = mappedCategories.ContainsKey(parentId) ? mappedCategories[parentId] : categoryService.GetCategoryById(parentId);
                }
            }

            return result;
        }
开发者ID:omidghorbani,项目名称:SmartStoreNET,代码行数:29,代码来源:CategoryExtensions.cs

示例3: GetCategoryBreadCrumb

        /// <summary>
        /// Get category breadcrumb 
        /// </summary>
        /// <param name="category">Category</param>
        /// <param name="categoryService">Category service</param>
        /// <param name="aclService">ACL service</param>
        /// <param name="storeMappingService">Store mapping service</param>
        /// <param name="showHidden">A value indicating whether to load hidden records</param>
        /// <returns>Category breadcrumb </returns>
        public static IList<Category> GetCategoryBreadCrumb(this Category category,
            ICategoryService categoryService,
            IAclService aclService,
            IStoreMappingService storeMappingService,
            bool showHidden = false)
        {
            if (category == null)
                throw new ArgumentNullException("category");

            var result = new List<Category>();

            //used to prevent circular references
            var alreadyProcessedCategoryIds = new List<int>();

            while (category != null && //not null
                !category.Deleted && //not deleted
                (showHidden || category.Published) && //published
                (showHidden || aclService.Authorize(category)) && //ACL
                (showHidden || storeMappingService.Authorize(category)) && //Store mapping
                !alreadyProcessedCategoryIds.Contains(category.Id)) //prevent circular references
            {
                result.Add(category);

                alreadyProcessedCategoryIds.Add(category.Id);

                category = categoryService.GetCategoryById(category.ParentCategoryId);
            }
            result.Reverse();
            return result;
        }
开发者ID:LaOrigin,项目名称:Leorigin,代码行数:39,代码来源:CategoryExtensions.cs

示例4: GetCategoryNameWithPrefix

        public static string GetCategoryNameWithPrefix(this Category category, ICategoryService categoryService)
        {
            string result = string.Empty;

            while (category != null)
            {
                if (String.IsNullOrEmpty(result))
                    result = category.Name;
                else
                    result = "--" + result;
                category = categoryService.GetCategoryById(category.ParentCategoryId);
            }
            return result;
        }
开发者ID:pquic,项目名称:qCommerce,代码行数:14,代码来源:CategoryExtensions.cs

示例5: GetCategoryBreadCrumb

        public static string GetCategoryBreadCrumb(this Category category, ICategoryService categoryService)
        {
            string result = string.Empty;

            while (category != null && !category.Deleted)
            {
                if (String.IsNullOrEmpty(result))
                    result = category.Name;
                else
                    result = category.Name + " >> " + result;

                category = categoryService.GetCategoryById(category.ParentCategoryId);

            }
            return result;
        }
开发者ID:pquic,项目名称:qCommerce,代码行数:16,代码来源:CategoryExtensions.cs

示例6: GetCategoryBreadCrumb

        public static IList<Category> GetCategoryBreadCrumb(this Category category, ICategoryService categoryService)
        {
            if (category == null)
                throw new ArgumentNullException("category");

            var result = new List<Category>();

            //used to prevent circular references
            while (category != null && !category.Deleted)
            {
                result.Add(category);
                category = categoryService.GetCategoryById(category.ParentCategoryId);
            }
            result.Reverse();
            return result;
        }
开发者ID:yubowave,项目名称:bongstore,代码行数:16,代码来源:CategoryExtension.cs

示例7: GetFormattedBreadCrumb

        /// <summary>
        /// Get formatted category breadcrumb 
        /// Note: ACL and store mapping is ignored
        /// </summary>
        /// <param name="category">Category</param>
        /// <param name="categoryService">Category service</param>
        /// <param name="separator">Separator</param>
        /// <param name="languageId">Language identifier for localization</param>
        /// <returns>Formatted breadcrumb</returns>
        public static string GetFormattedBreadCrumb(this Category category,
            ICategoryService categoryService,
            string separator = ">>", int languageId = 0)
        {
            if (category == null)
                throw new ArgumentNullException("category");

            string result = string.Empty;

            //used to prevent circular references
            var alreadyProcessedCategoryIds = new List<int>();

            while (category != null &&  //not null
                !category.Deleted &&  //not deleted
                !alreadyProcessedCategoryIds.Contains(category.Id)) //prevent circular references
            {
                var categoryName = category.GetLocalized(x => x.Name, languageId);
                if (String.IsNullOrEmpty(result))
                {
                    result = categoryName;
                }
                else
                {
                    result = string.Format("{0} {1} {2}", categoryName, separator, result);
                }

                alreadyProcessedCategoryIds.Add(category.Id);

                category = categoryService.GetCategoryById(category.ParentCategoryId);

            }
            return result;
        }
开发者ID:LaOrigin,项目名称:Leorigin,代码行数:42,代码来源:CategoryExtensions.cs

示例8: GetCartItems

 public List<Cart> GetCartItems(ICartService cartService, IProductService productService, ICategoryService categoryService)
 {
     var results = new List<Cart>();
     var cartItems = cartService.ODataQueryable().Where(x => x.CartId == ShoppingCartId).ToList();
     foreach (var item in cartItems)
     {
         item.Product = productService.GetProductById(item.ProductId);
         item.CategoryAlias = categoryService.GetCategoryById(item.Product.CategoryId).Alias;
         results.Add(item);
     }
     return results;
 }
开发者ID:thuyhk,项目名称:ThuanThienVN,代码行数:12,代码来源:ShoppingCart.cs


注:本文中的ICategoryService.GetCategoryById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。