Exemplo n.º 1
0
 private static void AddChildren(DocumentCategoryList hierarchy, DocumentCategory parentDocumentCategory, int depth, DocumentCategoryList allDocumentCategories)
 {
     foreach (var checkDocumentCategory in allDocumentCategories)
     {
         if (checkDocumentCategory.ParentDocumentCategoryID == parentDocumentCategory.ID)
         {
             var childDocumentCategory = checkDocumentCategory;
             childDocumentCategory["Depth"].ValueObject = depth;
             hierarchy.Add(childDocumentCategory);
             AddChildren(hierarchy, childDocumentCategory, depth + 1, allDocumentCategories);
         }
     }
 }
Exemplo n.º 2
0
        public ActionResult DocumentCategoryRoot(Page page)
        {
            /* Root Categories */
            var data = new DocumentCategoryViewModel();

            data.Categories = DocumentCategoryList.LoadByPageID(page.ID);
            data.Documents  = new DocumentList();

            /* we dont want to get the documents at this stage as its the root and we are not in a category
             * foreach (DocumentCategory category in data.Categories) {
             *      if (category.Documents.Count > 0) {
             *              foreach (var document in category.Documents) {
             *                      data.Documents.Add(document);
             *              }
             *      }
             * }
             */
            return(View("DocumentCategory", data));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a list of all page, in order with children underneath their parents and with an extra virtual field called Depth
        /// </summary>
        /// <returns></returns>
        public static DocumentCategoryList GetDocumentCategoryHierarchy()
        {
            var documentCategoryHierarchy = new DocumentCategoryList();
            var documentCategories        = DocumentCategoryList.Load(new Sql("select *, 0 as Depth from DocumentCategory order by SortPosition,DocumentCategoryID"));

            foreach (var documentCategory in documentCategories)
            {
                //page["Depth"].ValueObject = GetDepth(page, pages);

                if (documentCategory.ParentDocumentCategory == null)
                {
                    // top level page
                    documentCategory["Depth"].ValueObject = 0;
                    documentCategoryHierarchy.Add(documentCategory);
                    AddChildren(documentCategoryHierarchy, documentCategory, 1, documentCategories);
                }
            }

            return(documentCategoryHierarchy);
        }