//Lấy ra những sảng phẩm nào thuộc ProductCategory có ShowOnHome = true /// <summary> /// index : 0 => Get all /// index : 1 => Select by input quanlity /// </summary> /// <param name="index"></param> /// <param name="quanlity"></param> /// <returns></returns> public List <Product> productsOfProdCateforyShowOnHome(int index, int quanlity) { List <Product> lstproductsOfProdCateforyShowOnHome = new List <Product>(); var ProdCateDAO = new ProductCategoryDAO(); var ProdCateShowOnHomeID = ProdCateDAO.ProCategoryShowOnHome().ID; if (index == 0) { lstproductsOfProdCateforyShowOnHome = db.Products.Where(x => x.CategoryID == ProdCateShowOnHomeID && x.Status == true).ToList(); } else if (index == 1) { lstproductsOfProdCateforyShowOnHome = db.Products.Where(x => x.CategoryID == ProdCateShowOnHomeID && x.Status == true).Take(quanlity).ToList(); } return(lstproductsOfProdCateforyShowOnHome); }
public void SelectViewBag(long? selectedID = null) { var dao = new ProductCategoryDAO(); ViewBag.CategoryID = new SelectList(dao.ListProductCategory(), "ID", "Name", selectedID); }