public IndexProductAdminPanelViewModel GetAllProduct(int pageId = 1, string codeFilter = "" , string nameFilter = "") { IQueryable <Product> result = _context.Products; if (!string.IsNullOrEmpty(codeFilter)) { result = result.Where(u => u.ProductCode.Contains(codeFilter)); } if (!string.IsNullOrEmpty(nameFilter)) { result = result.Where(u => u.Name.Contains(nameFilter)); } // Show Item In Page int take = 100; int skip = (pageId - 1) * take; IndexProductAdminPanelViewModel item = new IndexProductAdminPanelViewModel() { CurrentPage = pageId, PageCount = result.Count() / take, Products = result.OrderBy(u => u.CreatDate).Skip(skip).Take(take).OrderByDescending(c => c.CreatDate).ToList() }; return(item); }
public void OnGet(int pageId = 1, string codeFilter = "", string nameFilter = "") { IndexProduct = _productService.GetAllProduct(pageId, codeFilter, nameFilter); }