Beispiel #1
0
        public static MvcHtmlString CreatPageLiTag(this UrlHelper urlHelper,
                                           BasePageModel pageModel,
                                           int index,
                                           bool isCurrentIndex = false,
                                           bool isDisable = true,
                                           string content = "")
        {
            string url = urlHelper.Action(pageModel.ActionName, new { searchkey = pageModel.SearchKeyWord, index = index });
            string activeClass = !isCurrentIndex ? string.Empty : "class='active'";
            string disableClass = isDisable ? string.Empty : "class='disabled'";
            url = isDisable ? "href='" + url + "'" : string.Empty;
            string contentString = string.IsNullOrEmpty(content) ? index.ToString() : content;

            return new MvcHtmlString("<li " + activeClass + disableClass + "><a " + url + ">" + contentString + "</a></li>");
        }
Beispiel #2
0
        public ActionResult List(string searchkey, string index)
        {
            if (string.IsNullOrEmpty(index))
                index = "1";
            if (string.IsNullOrEmpty(searchkey))
                searchkey = string.Empty;
            else
                searchkey = searchkey.ToLower();

            List<Product> lstProduct = Product.FindAll().ToList();

            List<Product> totalList = lstProduct.Where(p =>
                p.ProductName.Contains(searchkey)
                || (p.SuitCar != null && p.SuitCar.Contains(searchkey))
                ).ToList();

            BasePageModel page = new BasePageModel("List") { SearchKeyWord = searchkey, CurrentIndex = Int32.Parse(index), TotalCount = totalList.Count };

            List<Product> pageList = totalList.Skip((page.CurrentIndex - 1) * page.PageSize).Take(page.PageSize).ToList();
            ViewData["pagemodel"] = page;
            ViewBag.SearchKey = searchkey;
            return View(pageList);

            //return View(Product.FindAll());
        }