Пример #1
0
        private object GetProductDetail(long?id, string searchText, int PageNumber)
        {
            if (searchText == null)
            {
                searchText = "";
            }
            if (PageNumber <= 0)
            {
                PageNumber = 1;
            }
            int PageSkip = (PageNumber - 1) * PageOffSet;


            List <Product> ProductList = db.Product.Where(p => p.Idparent > 0 && p.Name.Contains(searchText)).ToList();

            if (id != null)
            {
                ProductList = ProductList.Where(p => p.Idparent == id).ToList();
            }
            ProductList = ProductList.Skip(PageSkip)
                          .Take(PageOffSet)
                          .ToList();

            VmProductDetail vmProductDetail = new VmProductDetail();

            vmProductDetail.ProductList = ProductList;
            vmProductDetail.AllPage     = (db.Product.Where(p => p.Idparent > 0).Count() / 10) + 1;
            vmProductDetail.CurrentPage = PageNumber;
            return(vmProductDetail);
        }
        private object Getdata(string SearchText, int PageNumber)
        {
            if (SearchText == null)
            {
                SearchText = "";
            }
            if (PageNumber <= 0)
            {
                PageNumber = 1;
            }
            int PageSkip = (PageNumber - 1) * PageOffSet;

            List <Product> ListProduct = db.Product
                                         .Where(p => p.StateDelete == false && p.Idparent != 0 && p.Name.Contains(SearchText))
                                         .OrderBy(u => u.Id)
                                         .Skip(PageSkip)
                                         .Take(PageOffSet)
                                         .ToList();

            VmProductDetail _VmProductDetail = new VmProductDetail();

            _VmProductDetail.ProductList = ListProduct;
            _VmProductDetail.AllPage     = (db.Product.Where(p => p.StateDelete == false && p.Idparent != 0).Count() / 10) + 1;
            _VmProductDetail.CurrentPage = PageNumber;
            return(_VmProductDetail);
        }