Пример #1
0
        public JsonResult LoadData(string name, string status, int page, int pageSize)
        {
            var model = ProductBus.List();

            if (!string.IsNullOrEmpty(name))
            {
                model = model.Where(x => x.Name.ToUpper().Contains(name.ToUpper()));
            }

            if (!string.IsNullOrEmpty(status))
            {
                var statusBool = bool.Parse(status);
                model = model.Where(x => x.Status == statusBool);
            }

            int totalRow = model.Count();

            model = model.Skip((page - 1) * pageSize).Take(pageSize);
            return(Json(new
            {
                data = model,
                total = totalRow,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        // GET: Product/
        public ActionResult Index(int?BrandId, int?currentBrand, int?CateId, int?currentCate, int?TypeId, int?currentType, string currentFilter, string SearchString, int page = 1, int pageSize = 4)
        {
            ViewBag.BrandId = new SelectList(BrandBus.List(), "Id", "Name");
            ViewBag.CateId  = new SelectList(CategoryBus.List().Where(x => x.Status == true), "Id", "Name");
            ViewBag.TypeId  = new SelectList(TypeBus.List(), "Id", "Name");

            if (SearchString != null)
            {
                page = 1;
            }
            else
            {
                SearchString = currentFilter;
            }
            ViewBag.CurrentFilter = SearchString;

            if (CateId != null)
            {
                page = 1;
            }
            else
            {
                CateId = currentCate;
            }
            ViewBag.CurrentCate = CateId;

            if (TypeId != null)
            {
                page = 1;
            }
            else
            {
                TypeId = currentType;
            }
            ViewBag.CurrentType = TypeId;

            if (BrandId != null)
            {
                page = 1;
            }
            else
            {
                BrandId = currentBrand;
            }
            ViewBag.CurrentBrand = BrandId;

            var model = ProductBus.List().Where(x => x.Status == true);

            if (!string.IsNullOrEmpty(SearchString))
            {
                model = model.Where(x => x.Description.ToLower().Contains(SearchString.ToLower()) || x.Name.ToLower().Contains(SearchString.ToLower()));
            }
            if (BrandId != null)
            {
                model = model.Where(x => x.BrandId == BrandId);
            }

            ViewBag.CurrentBrand = BrandId;
            if (CateId != null)
            {
                model = model.Where(x => x.CateId == CateId);
            }
            if (TypeId != null)
            {
                model = model.Where(x => x.TypeId == TypeId);
            }
            return(View(model.ToPagedList(page, pageSize)));
        }
Пример #3
0
 public ActionResult Index()
 {
     ViewBag.Logo = BrandBus.List();
     return(View(ProductBus.List().Where(x => x.Status == true).Take(8)));
 }