コード例 #1
0
        public ActionResult Index(SearchItemModel Model, int?page)
        {
            var pageNumber = page ?? 1;
            int total      = new int();
            List <ItemDisplayModel> lstModel    = new List <ItemDisplayModel>();
            List <GetCatetoryModel> lstcombobox = new List <GetCatetoryModel>();

            if (!string.IsNullOrEmpty(Session["code"] as string))
            {
                Model.code = Session["code"].ToString();
            }
            if (!string.IsNullOrEmpty(Session["name"] as string))
            {
                Model.name = Session["name"].ToString();
            }
            if (Session["category_id"] as int? != null)
            {
                Model.category_id = (int)Session["category_id"];
            }
            _itemBLL.Search(Model, out lstModel, out total, pageNumber);
            var list = new StaticPagedList <ItemDisplayModel>(lstModel, pageNumber, 15, total);

            ViewBag.ListSearch = lstModel.OrderByDescending(x => x.id);
            _itemBLL.GetCategory(true, out lstcombobox);
            ViewBag.lstcombobox = lstcombobox;
            ViewBag.page        = 0;
            if (page != null)
            {
                ViewBag.page = pageNumber - 1;
            }
            return(View(new Tuple <SearchItemModel, IPagedList <ItemDisplayModel> >(Model, list)));
        }