Пример #1
0
        public static void MoveCategoryDown(int categoryId)
        {
            Category source = new Category();

            if (source.LoadByPrimaryKey(categoryId))
            {
                //SELECT TOP 1 *
                //FROM DNNspot_Store_Category WHERE StoreId = 1 AND ParentId IS NULL AND SortOrder >= 3 AND Id <> 33
                //ORDER BY SortOrder ASC
                CategoryQuery q = new CategoryQuery();
                q.es.Top = 1;
                q.Where(q.StoreId == source.StoreId);
                if (source.ParentId.HasValue)
                {
                    q.Where(q.ParentId == source.ParentId.Value);
                }
                else
                {
                    q.Where(q.ParentId.IsNull());
                }
                q.Where(q.SortOrder >= source.SortOrder);
                q.Where(q.Id != categoryId);
                q.OrderBy(q.SortOrder.Ascending);

                Category dest = new Category();
                if (dest.Load(q))
                {
                    SwapAndReNumberSortOrder(source, dest);
                }
            }
        }
        public static List <Category> GetTopLevelCategories(int storeId, bool includeHidden)
        {
            CategoryQuery qry = new CategoryQuery();

            qry.Where(qry.StoreId == storeId);
            qry.Where(qry.ParentId.IsNull());
            if (!includeHidden)
            {
                qry.Where(qry.IsDisplayed == true);
            }
            qry.OrderBy(qry.SortOrder.Ascending, qry.Name.Ascending);

            CategoryCollection rootCategories = new CategoryCollection();

            rootCategories.Load(qry);

            List <Category> catList = new List <Category>(rootCategories.Count);

            foreach (var c in rootCategories)
            {
                catList.Add(c);
            }

            //return rootCategories;
            return(catList);
        }
Пример #3
0
        public CategoryCollection GetChildCategoriesInSortedOrder(bool includeHidden)
        {
            //SortChildCategories();
            //return this.CategoryCollectionByParentId;

            CategoryQuery q = new CategoryQuery();

            q.Where(q.ParentId == this.Id.Value);
            if (!includeHidden)
            {
                q.Where(q.IsDisplayed == true);
            }
            q.OrderBy(q.SortOrder.Ascending, q.Name.Ascending);

            CategoryCollection collection = new CategoryCollection();

            collection.Load(q);

            return(collection);
        }