public IEnumerable <shCategory> DanhSachCategory() { shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> dsCategory = _category.FindList() .Where(x => x.Status == true) .OrderBy(x => x.CategoryId); return(dsCategory); }
public IEnumerable <shCategory> DanhSachCategory_ByParentId(string ParentId) { shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> dsCategory = _category.FindList() .Where(x => x.Status == true && x.ParentId == ParentId) .OrderBy(x => x.CategoryId); return(dsCategory); }
public IEnumerable <shProduct> DanhSachProduct_ByUserId(int?UserId) { List <shProduct> dsProduct = new List <shProduct>(); if (UserId.HasValue) { shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> dsParent = _category.FindList().Where(x => x.UserId == UserId); foreach (var parent in dsParent) { if (!string.IsNullOrEmpty(parent.ParentId) || !string.IsNullOrWhiteSpace(parent.ParentId)) // là danh mục con.. Chỉ được load danh mục con { dsProduct.AddRange(DanhSachProduct_TheoDanhMuc(parent.CategoryGuid)); } else // là danh mục cha => tìm các danh muc con { dsProduct.AddRange(DanhSachProduct_TheoDanhMuc(parent.CategoryGuid)); IEnumerable <shCategory> dsChild = _category.DanhSachCategory_ByParentId(parent.CategoryGuid); foreach (var child in dsChild) { if (child.UserId.HasValue) { if (child.UserId == UserId) { dsProduct.AddRange(DanhSachProduct_TheoDanhMuc(child.CategoryGuid)); } } else { dsProduct.AddRange(DanhSachProduct_TheoDanhMuc(child.CategoryGuid)); } } } } } else { dsProduct = DanhSachProduct().ToList(); } return(dsProduct.OrderBy(x => x.ProductId)); }
public IEnumerable <shCategory> GetCategoryByParentId(string CategoryGuid) { shCategoryService _categories = new shCategoryService(); return(_categories.FindList().Where(x => x.ParentId == CategoryGuid)); }