Ejemplo n.º 1
0
        public IEnumerable<CategoryNode> GetCategoryTree(int accountID)
        {
            ICategoryRepository categoryRepository = new CategoryRepository();
            NotesRepository notesRepository = new NotesRepository();

            IEnumerable<Category> categories = categoryRepository.GetCategories(accountID);
            IEnumerable<Note> notes = notesRepository.GetCategoryNotes(accountID);

            List<CategoryNode> rootNodes = new List<CategoryNode>();

            IEnumerable<Category> roots = categories.Where(p => p.ParentCategoryID == 0);

            foreach (Category child in roots)
            {
                CategoryNode node = new CategoryNode();
                node.Value = child;

                node.Notes = notes.Where(p => p.CategoryID == child.CategoryID).ToList();

                rootNodes.Add(node);

                attachChildren(node, categories, notes);
            }

            return rootNodes;
        }
Ejemplo n.º 2
0
 public NotesController()
 {
     notesRepository = new NotesRepository();
 }