private void BuildChildNode(CategoryViewModel cat) { if (cat != null) { var children = _uow.Categories.AllIncluding(c => c.Children).Where(c => c.Parent.Id == cat.Id) .Project().To<CategoryViewModel>().ToList(); if (children != null) { foreach (var child in children) { BuildChildNode(child); cat.Children.Add(child); } } } }
private void ToSelectList(CategoryViewModel cat, List<SelectListItem> list) { if (cat.Children != null) { foreach (var item in cat.Children) { list.Add(new SelectListItem() { Value = item.Id.ToString(), Text = Prefix(2 * item.Depth) + item.Name }); ToSelectList(item, list); } } }