public async Task <IActionResult> Index(int page = 1, string contain = null) { ViewBag.currentPage = page; ViewBag.totalPage = TotalPage(ProductBLL.Cout()); if (contain != null) { var ListResult = await ProductBLL.Get(numberPerPage, page, filter : p => p.Model.Contains(contain)); ViewBag.currentPage = page; ViewBag.totalPage = TotalPage(ProductBLL.Cout(filter: p => p.Model.Contains(contain))); return(View(ListResult)); } var listProduct = await ProductBLL.Get(numberPerPage, page, orderBy : p => p.OrderByDescending(x => x.EditedDate)); return(View(listProduct)); }
public async Task <IActionResult> Search(int page = 1, string Search = null) { IEnumerable <Product> listProduct = null; if (Search != null) { listProduct = await productBLL.Get(ViewHelpers.NumberPerPageFront, page, filter : p => p.Model.Contains(Search), orderBy : p => p.OrderByDescending(product => product.EditedDate)); ViewBag.page = page; int totalCount = productBLL.Cout(p => p.Model.Contains(Search)); ViewBag.totalpage = ViewHelpers.TotalPage(totalCount, ViewHelpers.NumberPerPageFront); } return(View("~/Views/Shop/ShopAll.cshtml", listProduct)); }
public async Task <IActionResult> ShopAll(int page = 1, string typesex = null) { IEnumerable <Product> listProducts = null; if (typesex == "nam") { listProducts = await ProductBLL.Get(intNumber : numberPerPage, currentPage : page, filter : p => p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.Male || p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.All); ViewBag.page = page; ViewBag.Title = "Sản phẩm dành cho nam"; ViewBag.totalpage = TotalPage(ProductBLL.Cout(filter: p => p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.Male || p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.All)); } else if (typesex == "nu") { listProducts = await ProductBLL.Get(intNumber : numberPerPage, currentPage : page, filter : p => p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.Female || p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.All); ViewBag.page = page; ViewBag.Title = "Sản phẩm dành cho nữ"; ViewBag.totalpage = TotalPage(ProductBLL.Cout(filter: p => p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.Female || p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.All)); } else if (typesex == null) { listProducts = await ProductBLL.Get(intNumber : numberPerPage, currentPage : page); ViewBag.page = page; ViewBag.Title = "Danh sách Sản phẩm "; ViewBag.totalpage = TotalPage(ProductBLL.Cout(filter: p => p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.Female || p.SubGroup.MainGroup.TypeSex == Common.Enum.PM.TypeSexEnum.All)); } else { NotFound(); } return(View(listProducts)); }