Example #1
0
        public void SaveCategory()
        {
            ISite             ist = this.siteRepo.GetSiteById(siteId);
            CmsCategoryEntity cat = new CmsCategoryEntity
            {
                SiteId   = siteId,
                Name     = "一级分类",
                ParentId = 0,
                Tag      = "cat1",
                Location = "http://baidu.com",
            };
            ICategory ic = ist.GetCategoryByPath("cat1");

            if (ic == null)
            {
                ic = this.repo.CreateCategory(cat);
            }
            Error err = ic.Set(cat);

            if (err == null)
            {
                TemplateBind[] arr = new TemplateBind[2];
                arr[0] = new TemplateBind(0, TemplateBindType.CategoryArchiveTemplate, "default/archive_1");
                arr[1] = new TemplateBind(0, TemplateBindType.CategoryTemplate, "default/category_1");
                err    = ic.SetTemplates(arr);
                if (err == null)
                {
                    err = ic.Save();
                }
            }
            if (err != null)
            {
                Assert.Fail(err.Message);
            }
            else
            {
                this.Println(this.Stringfy(ic.Get()));
                this.Println(this.Stringfy(ist.GetCategoryTreeWithRootNode()));
                cat.Name += "*";
                ic.Set(cat);
                ic.Save();
                this.Println(this.Stringfy(ist.GetCategoryTreeWithRootNode()));
            }
        }
Example #2
0
        public TreeNode GetCategoryTreeWithRootNode(int siteId)
        {
            ISite site = this.repo.GetSiteById(siteId);

            return(site.GetCategoryTreeWithRootNode());
        }
Example #3
0
        public void TestGetCategoryTreeNode()
        {
            ISite ist = this.siteRepo.GetSiteById(siteId);

            this.Println(this.Stringfy(ist.GetCategoryTreeWithRootNode()));
        }