Beispiel #1
0
        public static bool DeleteCategory(int categoryId)
        {
            ManagerHelper.CheckPrivilege(Privilege.DeleteProductCategory);
            CategoryInfo category = CatalogHelper.GetCategory(categoryId);

            if (category == null)
            {
                return(false);
            }
            bool flag = new CategoryDao().DeleteCategory(categoryId, category.Path);

            if (flag)
            {
                EventLogs.WriteOperationLog(Privilege.DeleteProductCategory, string.Format(CultureInfo.InvariantCulture, "删除了编号为 “{0}” 的店铺分类", new object[1]
                {
                    categoryId
                }), false);
                HiCache.Remove("DataCache-Categories");
            }
            return(flag);
        }
Beispiel #2
0
        public static IList <CategoryInfo> GetSequenceCategories(string categoryname = "")
        {
            IList <CategoryInfo> list = null;

            if (!string.IsNullOrEmpty(categoryname))
            {
                CategoriesQuery categoriesQuery = new CategoriesQuery();
                categoriesQuery.Name = categoryname;
                list = CatalogHelper.GetCategoryList(categoriesQuery);
            }
            else
            {
                list = new List <CategoryInfo>();
                IEnumerable <CategoryInfo> mainCategories = CatalogHelper.GetMainCategories();
                foreach (CategoryInfo item in mainCategories)
                {
                    list.Add(item);
                    CatalogHelper.LoadSubCategorys(item.CategoryId, list);
                }
            }
            return(list);
        }
Beispiel #3
0
        public static bool AddCategory(CategoryInfo category)
        {
            if (category == null)
            {
                return(false);
            }
            CategoryDao categoryDao = new CategoryDao();

            category.CategoryId = categoryDao.GetMaxDisplaySequence <CategoryInfo>();
            int categoryId;

            if (category.ParentCategoryId > 0)
            {
                CategoryInfo category2 = CatalogHelper.GetCategory(category.ParentCategoryId);
                string       path      = category2.Path;
                categoryId     = category.CategoryId;
                category.Path  = path + "|" + categoryId.ToString();
                category.Depth = category2.Depth + 1;
            }
            else
            {
                categoryId     = category.CategoryId;
                category.Path  = categoryId.ToString();
                category.Depth = 1;
            }
            Globals.EntityCoding(category, true);
            bool flag = categoryDao.Add(category, null) > 0;

            if (flag)
            {
                EventLogs.WriteOperationLog(Privilege.AddProductCategory, string.Format(CultureInfo.InvariantCulture, "创建了一个新的店铺分类:”{0}”", new object[1]
                {
                    category.Name
                }), false);
                HiCache.Remove("DataCache-Categories");
            }
            return(flag);
        }
Beispiel #4
0
 public static CategoryInfo GetCategory(int categoryId)
 {
     return(CatalogHelper.GetCategories().FirstOrDefault((CategoryInfo item) => item.CategoryId == categoryId));
 }
Beispiel #5
0
 public static IEnumerable <CategoryInfo> GetMainCategories()
 {
     return(from item in CatalogHelper.GetCategories()
            where item.Depth == 1
            select item);
 }
Beispiel #6
0
 public static IEnumerable <CategoryInfo> GetSubCategories(int parentCategoryId)
 {
     return(from item in CatalogHelper.GetCategories()
            where item.ParentCategoryId == parentCategoryId
            select item);
 }