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, })); }
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 })); }