public ActionResult CategoryLeft(bool?IsMenuChild) { if (!IsMenuChild.HasValue) { IsMenuChild = false; } shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> dsCategory = _category.DanhSachCategory() .Where(x => string.IsNullOrEmpty(x.ParentId) || string.IsNullOrWhiteSpace(x.ParentId)) .ToList(); List <shCategory> dsDanhMuc = dsCategory.ToList(); if (IsMenuChild.Value) { foreach (var item in dsCategory) { dsDanhMuc.AddRange(_category.DanhSachCategory_ByParentId(item.CategoryGuid)); } } return(PartialView("CategoryLeft", dsDanhMuc)); }
public ActionResult divProduct() { shCategoryService _category = new shCategoryService(); IEnumerable <shCategory> ds = _category.DanhSachCategory(); return(PartialView("divProduct", ds)); }
public ActionResult Index(int?id) { shCategoryService _category = new shCategoryService(); if (!id.HasValue) { // Nếu link truyền vào không có id ( ví dụ link tổng quát: san-pham thì mặc định lấy trang danh mục đầu tiên) id = _category.DanhSachCategory().FirstOrDefault().CategoryId; } shCategory category = _category.FindList().Where(x => x.CategoryId == id).FirstOrDefault(); ViewBag.CategoryGuid = category.CategoryGuid; DsProduct(category.CategoryGuid, 1); return(View(category)); }
public PartialViewResult ListCategory(int?page) { int pageCurrent = 1; if (page.HasValue) { pageCurrent = page.Value; } shCategoryService _category = new shCategoryService(); IPagedList <shCategory> dsCategory = _category.DanhSachCategory().Where(x => x.TopHot != true).ToPagedList(pageCurrent, Config.PAGE_SIZE_10); ViewBag.ListCategory = dsCategory; return(PartialView("ListCategory", dsCategory)); }
public static int?FindPageCategory(string CategoryGuid, int?CategoryId) { try { shCategoryService _category = new shCategoryService(); List <shCategory> dsCategory = _category.DanhSachCategory().ToList(); int index = dsCategory.FindIndex(x => x.CategoryGuid == CategoryGuid); index = (int)index / Config.PAGE_SIZE_10; index++; return(index); } catch (Exception) { return(1); } }
public List <TreeView> GetCategoryTreeview(bool isProduct) { shCategoryService _categories = new shCategoryService(); IEnumerable <shCategory> dsCategory = _categories.DanhSachCategory() .Where(x => string.IsNullOrWhiteSpace(x.ParentId)) .OrderBy(x => x.CategoryId); List <TreeView> dsTreeView = new List <TreeView>(); TreeView zTree = null; TreeView childZtree = null; foreach (var item in dsCategory) { zTree = new TreeView(); //zTree.open = soDem == 0 ? true : false; zTree.isParent = true; zTree.id = item.CategoryGuid; zTree.pId = item.ParentId; IEnumerable <shCategory> dsChildCategory = _categories.GetCategoryByParentId(item.CategoryGuid).OrderBy(x => x.CategoryId); List <TreeView> dsChildTreeview = null; if (dsChildCategory.Count() > 0) // Có phần tử con { dsChildTreeview = new List <TreeView>(); foreach (var childCategory in dsChildCategory) { childZtree = new TreeView(); childZtree.id = childCategory.CategoryGuid; childZtree.pId = childCategory.ParentId; childZtree.name = childCategory.CategoryName; if (isProduct) { // TRUE Áp dụng cho hiển thị Danh sách sản phẩm theo danh mục childZtree.isParent = isProduct; childZtree.children = ProductByCategoryGuid(childCategory.CategoryGuid); //childZtree.open = true; childZtree.click = "category('" + childCategory.CategoryId + "')"; if (childZtree.children != null && childZtree.children.Count() > 0) { childZtree.name = childCategory.CategoryName + "[" + childZtree.children.Count() + "]"; } } else { // FALSE Áp dụng KHÔNG hiển thị Danh sách sản phẩm theo danh mục childZtree.isParent = isProduct; childZtree.children = null; //childZtree.open = false; childZtree.click = "category('" + childCategory.CategoryId + "')"; } dsChildTreeview.Add(childZtree); } zTree.children = dsChildTreeview; zTree.open = true; zTree.click = "category('" + item.CategoryId + "')"; zTree.name = item.CategoryName + " (" + dsChildCategory.Count() + ")"; } else { zTree.click = "category('" + item.CategoryId + "')"; zTree.open = false; // zTree.name = item.CategoryName; } if (isProduct) { zTree.children.AddRange(ProductByCategoryGuid(item.CategoryGuid)); if (zTree.children.Count() > 0) { zTree.open = true; } } //zTree.name += "(" + zTree.children.Count() + ")"; dsTreeView.Add(zTree); } return(dsTreeView); }