本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}