public IEnumerable <Category> getProductByCategory(int parentId) { List <Category> result = new List <Category>(); result.Add(_businessCategory.GetById(parentId)); var children = _businessCategory.GetAll().Where(i => i.ParentId == parentId).ToList(); foreach (var item in children) { result.AddRange(getProductByCategory(item.Id)); } return(result); }
public Category GetById(int id) { return(business.GetById(id)); }