Ejemplo n.º 1
0
        public ActionResult PriceCityIndex(int?page, string currentPriceCityName)
        {
            if (Request.HttpMethod == "GET")
            {
                if (Session["PriceCityName"] != null)
                {
                    currentPriceCityName     = Session["PriceCityName"].ToString();
                    Session["PriceCityName"] = null;
                }
            }
            else
            {
                page = 1;
            }

            ViewBag.CurrentPriceCityName = currentPriceCityName;

            var all = db.sp_PriceCity_GetByAll().OrderBy(p => p.Level).ToList();

            if (!String.IsNullOrEmpty(currentPriceCityName))
            {
                all = all.Where(p => p.Name.ToUpper().Contains(currentPriceCityName.ToUpper())).OrderBy(p => p.Level).ToList();
            }

            int pageSize   = 25;
            int pageNumber = (page ?? 1);

            // Thiết lập phân trang
            PagedListRenderOptions ship = new PagedListRenderOptions();

            ship.DisplayLinkToFirstPage                      = PagedListDisplayMode.Always;
            ship.DisplayLinkToLastPage                       = PagedListDisplayMode.Always;
            ship.DisplayLinkToPreviousPage                   = PagedListDisplayMode.Always;
            ship.DisplayLinkToNextPage                       = PagedListDisplayMode.Always;
            ship.DisplayLinkToIndividualPages                = true;
            ship.DisplayPageCountAndCurrentLocation          = false;
            ship.MaximumPageNumbersToDisplay                 = 5;
            ship.DisplayEllipsesWhenNotShowingAllPageNumbers = true;
            ship.EllipsesFormat                     = "…";
            ship.LinkToFirstPageFormat              = "Trang đầu";
            ship.LinkToPreviousPageFormat           = "«";
            ship.LinkToIndividualPageFormat         = "{0}";
            ship.LinkToNextPageFormat               = "»";
            ship.LinkToLastPageFormat               = "Trang cuối";
            ship.PageCountAndCurrentLocationFormat  = "Page {0} of {1}.";
            ship.ItemSliceAndTotalFormat            = "Showing items {0} through {1} of {2}.";
            ship.FunctionToDisplayEachPageNumber    = null;
            ship.ClassToApplyToFirstListItemInPager = null;
            ship.ClassToApplyToLastListItemInPager  = null;
            ship.ContainerDivClasses                = new[] { "pagination-container" };
            ship.UlElementClasses                   = new[] { "pagination" };
            ship.LiElementClasses                   = Enumerable.Empty <string>();

            ViewBag.ship = ship;

            return(View(all.ToPagedList(pageNumber, pageSize)));
        }