Ejemplo n.º 1
0
        public List <Category> GetCategories(bool includeHiddenCategories)
        {
            // This is correct, but there's a bug in ES that doesn't honor the DNN Object Qualifier for M2M collections :(
            //List<Category> categories = this.UpToCategoryCollection;
            //if (!includeHiddenCategories)
            //{
            //    categories.RemoveAll(c => !c.IsDisplayed.GetValueOrDefault());
            //}
            //return categories;

            //SELECT
            //c.*
            //FROM DNNspot_Store_Category c
            //INNER JOIN DNNspot_Store_ProductCategory pc ON pc.CategoryId = c.Id
            //WHERE pc.ProductId = 21

            CategoryQuery        c  = new CategoryQuery("c");
            ProductCategoryQuery pc = new ProductCategoryQuery("pc");

            c.Select(c).InnerJoin(pc).On(c.Id == pc.CategoryId);
            c.Where(pc.ProductId == this.Id.Value);

            CategoryCollection collection = new CategoryCollection();

            collection.Load(c);

            return(collection.ToList());
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
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();
            }
        }