Ejemplo n.º 1
0
        //public static List<CategoryNode> GetCategoryNodeTree()
        //{
        //    List<CategoryNode> cats = new List<CategoryNode>();
        //    cats.AddRange(GetTopLevelCategories().ConvertAll(c => new CategoryNode() { Category = c }));

        //    foreach (CategoryNode parentInfo in cats)
        //    {
        //        AddChildCategoryNodesRecursive(parentInfo);
        //    }

        //    return cats;
        //}

        //private static void AddChildCategoryNodesRecursive(CategoryNode parentInfo)
        //{
        //    parentInfo.SubCategories = ((List<Category>)parentInfo.Category.GetChildCategoriesInSortedOrder()).ConvertAll(c => new CategoryNode() { Category = c });

        //    foreach (CategoryNode child in parentInfo.SubCategories)
        //    {
        //        AddChildCategoryNodesRecursive(child);
        //    }
        //}

        internal static void UpdateAllNestingLevels()
        {
            CategoryCollection allCategories = new CategoryCollection();

            allCategories.LoadAll();

            foreach (Category cat in allCategories)
            {
                cat.NestingLevel = cat.GetNestingLevel();
            }
            allCategories.Save();
        }
Ejemplo n.º 2
0
        public static void SetSortOrderByListPosition(List <int> categoryIdsInSortOrder)
        {
            CategoryQuery q = new CategoryQuery();

            q.Where(q.Id.In(categoryIdsInSortOrder.ToArray()));

            CategoryCollection collection = new CategoryCollection();

            if (collection.Load(q))
            {
                for (short i = 0; i < categoryIdsInSortOrder.Count; i++)
                {
                    Category c = collection.FindByPrimaryKey(categoryIdsInSortOrder[i]);
                    if (c != null)
                    {
                        c.SortOrder = i;
                    }
                }
                collection.Save();
            }
        }