Beispiel #1
0
        public IActionResult GetCategoryAndSubcategories(int?id, int page = 1)
        {
            Category current;

            var tree = new CategoryTree(db.Category);

            if (id == null)
            {
                current = null;
            }
            else
            {
                current = tree.FindCategoryNode(id.Value)?.Category;
                if (current == null)
                {
                    return(View("NotFound"));
                }
            }

            var subtrees = tree.Subtrees(id).ToList();
            var products = ShowProductsInCategory(tree, id, page);

            return(View(new CategoryViewModel()
            {
                CategoryPath = tree.FindPath(current),
                Subtrees = subtrees,
                Products = products,
            }));
        }
Beispiel #2
0
        public IActionResult Categories()
        {
            var tree = new CategoryTree(db.Category);

            var subtrees = tree.Subtrees(null).ToList();

            return(View(new CategoryViewModel()
            {
                CategoryPath = tree.FindPath(null),
                Subtrees = subtrees
            }));
        }