当前位置: 首页>>代码示例>>C#>>正文


C# List.ToPagedList方法代码示例

本文整理汇总了C#中List.ToPagedList方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToPagedList方法的具体用法?C# List.ToPagedList怎么用?C# List.ToPagedList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


在下文中一共展示了List.ToPagedList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Results

        public ActionResult Results(int? page, string keywords = "")
        {
            string _keywords = keywords != null ? keywords.ToString().ToLower() : ""; 
            List<Work> works = new List<Work>();

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

            
            if(!string.IsNullOrEmpty(_keywords) && !string.IsNullOrWhiteSpace(_keywords))
            {
                works = (from wk in WorkBl.GetList()
                         where (wk.Description.ToLower().Contains(_keywords) ||
                         wk.Title.ToLower().Contains(_keywords) ||
                         wk.User.Name.ToLower().Contains(_keywords) ||
                         wk.User.Username.ToLower().Contains(_keywords))
                         orderby wk.Id descending
                         select wk).ToList();

                ViewBag.Keywords = _keywords;

                //paging                
                return View(works.ToPagedList(pageNumber, pageSize));
            }
            return View(works.ToPagedList(pageNumber, pageSize));            
        }
开发者ID:kudakwashegore,项目名称:Ndiringe,代码行数:26,代码来源:SearchController.cs

示例2: Index

        public ActionResult Index(int? page, int? PageSize, string sortBy)
        {
            var customers = new List<DSC_CUSTOMER>();
            var viewCustomers = new List<CustViewModel>();
            ViewBag.CurrentItemsPerPage = PageSize ?? 10;
            ViewBag.SortNameParameter = String.IsNullOrEmpty(sortBy) ? "Name desc" : "Name";
            ViewBag.SortParentParameter = sortBy == "Parent" ? "Parent desc" : "Parent"; 

            using (DSC_OBS_DB_ENTITY db = new DSC_OBS_DB_ENTITY())
            {
                customers = db.DSC_CUSTOMER.Where(cust_id => cust_id.dsc_cust_id > 0).ToList();
            }
            //DateTime active_date;
            foreach (DSC_CUSTOMER customer in customers)
            {
                string activeAction = "";
                try
                {
                    if (customer.dsc_cust_eff_end_date == null)
                    {
                        activeAction = "YES";

                    }//end of if
                    else
                    {
                        if (customer.dsc_cust_eff_end_date <= DateTime.Today)
                        {
                            activeAction = "NO";
                        }
                        else
                        {
                            activeAction = "YES";
                        }
                    }//end of else
                }//end of try
                catch
                {
                    activeAction = "NO";
                }//end of catch

                viewCustomers.Add(new CustViewModel(customer.dsc_cust_id, customer.dsc_cust_name, customer.dsc_cust_parent_name, activeAction, activeAction == "YES" ? "Deactivate" : "Activate"));
            }// end of foreach
            switch (sortBy)
            {
                case "Name desc":
                    return View(viewCustomers.OrderByDescending(x=>x.dsc_cust_name).ToPagedList(page ?? 1, PageSize ?? 10));
                case "Parent desc":
                    return View(viewCustomers.OrderByDescending(x => x.dsc_cust_parent_name).ToPagedList(page ?? 1, PageSize ?? 10));
                case"Name":
                    return View(viewCustomers.OrderBy(x => x.dsc_cust_name).ToPagedList(page ?? 1, PageSize ?? 10));
                case "Parent":
                    return View(viewCustomers.OrderBy(x => x.dsc_cust_parent_name).ToPagedList(page ?? 1, PageSize ?? 10));
                default: return View(viewCustomers.ToPagedList(page ?? 1, PageSize ?? 10));


            }

            
            
        }
开发者ID:dsclogistics,项目名称:OBSMVC,代码行数:60,代码来源:CustController.cs

示例3: Index

        public async Task<ActionResult> Index(int page = 1)
        {
            var entities = await hotelRep.Get().ToListAsync();

            var models = new List<HotelViewModel>();

            HotelViewModel model;

            foreach (var h in entities)
            {
                model = new HotelViewModel();
                model.Id = h.Id;
                model.Name = h.Name;
                model.RegionId = h.RegionId;
                model.RegionName = RegionToName(h.RegionId, "");
                model.Phone = h.Phone;
                model.Created = h.Created;
                model.Modified = h.Modified;
                model.Status = (HotelStatus)h.Status;
                var hotelImg = imgRep.FindById(h.Id, 0);
                if (hotelImg != null)
                {
                    model.ImgUrl = hotelImg.Url;
                }
                models.Add(model);
            }

            return View(models.ToPagedList(page, 10));
        }
开发者ID:oldkwok,项目名称:Kwop,代码行数:29,代码来源:HotelAdminController.cs

示例4: UserAlbum

 //
 // GET: /PhotoBook/UserAlbums
 public ActionResult UserAlbum(int page = 1)
 {
     var albumList = new List<AlbumViewModel>();
     var users = unitOfWork.UserRepository.Get();
     FillAlbumModel(users, albumList);
     return View(albumList.ToPagedList(page, Settings.Default.PhotosPerPage));
 }
开发者ID:nancy-bree,项目名称:PhotoBook,代码行数:9,代码来源:PhotoBookController.cs

示例5: Index

        public ActionResult Index(int? page)
        {
            if (Authentication.Checklogin())
            {
                int pageSize = 8;
                int pageNum = (page ?? 1);

                var _ListArea = _AreaService.GetAllAreaWithProject();
                var proObj = new List<AreaViewModel>();
                if (_ListArea != null)
                {
                    foreach (var item in _ListArea)
                    {
                        proObj.Add(
                                   new AreaViewModel()
                                   {
                                       AreaId = item.AreaId,
                                       AreaName = item.AreaName,
                                       Keyword = item.Keyword,
                                       MetaDescription = item.MetaDescription,
                                       NumOfProject = item.Projects.Count(t => t.IsDelete == false)
                                   });
                    }
                }
                ViewBag.Count = proObj.Count;
                var result = proObj.ToPagedList(pageNum, pageSize);
                ViewBag._ListArea = result;
                return View(result);
            }
            else
                return RedirectToAction("Index", "Login");
        }
开发者ID:dattienmdc,项目名称:SHTeam,代码行数:32,代码来源:AreaController.cs

示例6: SomeRows

        public JsonResult SomeRows(int? page, int? size)
        {
            List<DataRow> customers = new List<DataRow>();

            for (int i = 0; i < 23; i++)
            {
                customers.Add(new DataRow { Name = "Customer " + i.ToString(), DOB = (new DateTime().AddDays(i)) });
            }

            int pageNumber = page ?? 1;
            int pageSize = size ?? 5;
            var pageOfCustomers = customers.ToPagedList(pageNumber, pageSize);

            //double pageCount = System.Math.Round(totalPages,0,);
            var results = new ResultSet
            {
                Pages = pageOfCustomers.PageCount,
                Current = pageOfCustomers.PageNumber,
                IsFirst = pageOfCustomers.IsFirstPage,
                IsLast = pageOfCustomers.IsLastPage,
                HasPrevious = pageOfCustomers.HasPreviousPage,
                HasNext = pageOfCustomers.HasNextPage,
                Results = pageOfCustomers.ToList()
            };

            return Json(results);
        }
开发者ID:ragingsmurf,项目名称:jQuery-Pageable,代码行数:27,代码来源:HomeController.cs

示例7: Index

 public ActionResult Index(int ? page)
 {
     if (Authentication.Checklogin())
     {
         int pageSize = 8;
         int pageNum = (page ?? 1);
         var _ListPrice = _PriceService.GetAllPrice();
         var proObj = new List<PriceViewModel>();
         if (_ListPrice != null)
         {
             foreach (var item in _ListPrice)
             {
                 proObj.Add(
                            new PriceViewModel()
                            {
                                PriceId = item.PriceId,
                                PriceValue = item.PriceValue,
                                NumOfProjects = item.Projects.Count(t => t.IsDelete == false)
                            });
             }
         }
         ViewBag.Count = proObj.Count;
         var result = proObj.ToPagedList(pageNum, pageSize);
         ViewBag._ListPrice = result;
         return View(result);
     }
     else
         return RedirectToAction("Index", "Login");
 }
开发者ID:dattienmdc,项目名称:SHTeam,代码行数:29,代码来源:PriceController.cs

示例8: Index

        public ViewResult Index(string sortOrder, string currentFilterMMP, string currentFilterMDP, string minMonthlyPurchases, string minDollarPurchases, int? page)
        {
            int cr=0;
            int pageSize = 10;
            if (Request.HttpMethod == "GET")
            {
                minMonthlyPurchases = currentFilterMMP;
                minDollarPurchases = currentFilterMDP;
            }
            else
            {
                page = 1;
            }

            ViewBag.CurrentFilterMMP = minMonthlyPurchases;
            ViewBag.CurrentFilterMDP = minDollarPurchases;

            int pageNumber = (page ?? 1);

            if (minMonthlyPurchases != null && minDollarPurchases != null)
            {
                var Rewards = from s in serviceProxy.GetRewardsReport(sbyte.Parse(minMonthlyPurchases), decimal.Parse(minDollarPurchases), cr) select s;

                return View(Rewards.ToPagedList(pageNumber, pageSize));
            }
            else
            {
                List<SCustomer> sc = new List<SCustomer>();
                return View(sc.ToPagedList(1, 1));
            }
        }
开发者ID:Ecetera,项目名称:appdynamics-sandpit,代码行数:31,代码来源:RewardsController.cs

示例9: Details

        public async Task<ActionResult> Details(int id, int page = 1, int pageSize = 20)
        {
            if (id == default(int))
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            var role = await RoleManager.FindByIdAsync(id);

            if (role == null)
            {
                return HttpNotFound();
            }

            var users = new List<UserViewModel>();
            foreach (var user in UserManager.Users.ToList())
            {
                if (await UserManager.IsInRoleAsync(user.Id, role.Name))
                {
                    users.Add(new UserViewModel
                    {
                        UserName = user.UserName,
                        Email = user.Email,
                        PhoneNumber = user.PhoneNumber,
                        Created = user.Created
                    });
                }
            }

            ViewBag.RoleId = role.Id;
            ViewBag.RoleName = role.Name;
            ViewBag.RoleDescription = role.Description;
            return View(users.ToPagedList(page, 20));
        }
开发者ID:oldkwok,项目名称:Kwop,代码行数:34,代码来源:RolesAdminController.cs

示例10: Index

        public ActionResult Index(int page=1)
        {
            var locations = new List<Location>();
            using (var client = new HttpClient())
            {
                var task = client.GetAsync(url)
                    .ContinueWith(request =>
                                  {
                                      request.Result.EnsureSuccessStatusCode();
                                      var readTask=request.Result.Content.ReadAsAsync<List<Location>>()
                                          .ContinueWith(read =>
                                                        {
                                                            locations = read.Result;
                                                        });
                                      readTask.Wait();
                                  }).ContinueWith(error =>
                                                  {
                                                      if (error.Exception != null)
                                                          ViewBag.Error = error.Exception.StackTrace;
                                                  });
                task.Wait();
            }

            SetExtraData();

            return View(locations.ToPagedList(page, 6));
        }
开发者ID:shahid11,项目名称:Customers,代码行数:27,代码来源:HomeController.cs

示例11: Index

        public ActionResult Index(int ? Id,int ? page)
        {
            int pageSize = 5;
            int pageNum = (page ?? 1);

            ViewBag.Sektori = ctx.Sektoris.Where(x => x.IsActive == true).ToList();

            if(Id!=null)
            {
                int id = Id ?? default(int);
                Sektori s = ctx.Sektoris.Where(x => x.SektorID == id).SingleOrDefault();

                if (s != null)
                {
                    ViewData["Sektor"] = s;

                    List<ObavijestiSektori> sek = ctx.ObavijestiSektoris.Where(x => x.SektorID == s.SektorID && x.IsActive == true).OrderByDescending(x=>x.ObavijestSektorID).ToList();

                    List<Obavijesti> obavijesti = new List<Obavijesti>();

                    foreach (ObavijestiSektori item in sek)
                    {
                        Obavijesti o = ctx.Obavijestis.Where(x => x.ObavijestID == item.ObavijestID && x.IsActive == true).SingleOrDefault();

                        if (o != null)
                            obavijesti.Add(o);
                    }
                    return View(obavijesti.ToPagedList(pageNum, pageSize));
                }
            }
            return RedirectToAction("Index", "Index");
        }
开发者ID:semira27,项目名称:Projekat_2015,代码行数:32,代码来源:SektorController.cs

示例12: Index

        public ActionResult Index(int ? page )
        {
            if (Authentication.Checklogin())
            {
                int pageSize = 8;
                int pageNum = (page ?? 1);
                var _listProjectType = _projectType.GetListProjectType();
                var proObj = new List<ProjectTypeViewModel>();
                if (_listProjectType != null)
                {
                    foreach (var item in _listProjectType)
                    {
                        proObj.Add(
                                   new ProjectTypeViewModel()
                                   {
                                       Name = item.NameType,
                                       Image = item.Image,
                                       ProjectTypeId = item.ProjectTypeId,
                                       Description = item.Description,
                                       Keyword = item.Keyword,
                                       MetaDescription = item.MetaDescription,
                                       NumOfProject = item.Projects.Count(t=>t.IsDelete==false)
                                   });
                    }
                }

                ViewBag.Count = proObj.Count;
                var result = proObj.ToPagedList(pageNum, pageSize);
                ViewBag._listProjectType = result;
                return View(result);
            }
            else
                return RedirectToAction("Index", "Login");
        }
开发者ID:dattienmdc,项目名称:SHTeam,代码行数:34,代码来源:ProjectTypeController.cs

示例13: Index

        public ActionResult Index(string roleId, int index = 1)
        {
            //取role列表
            var roles = _roleManager.Roles.ToList();
            //roleId是否为空
            if (string.IsNullOrWhiteSpace(roleId))
            {
                //取第一个role的id
                roleId = roles.FirstOrDefault().Id;
            }
            //放入viewbag,设置默认值
            ViewBag.RoleID = new SelectList(roles, "ID", "Name", roleId);
            //取角色权限列表
            var permissions = _roleManager.GetRolePermissions(roleId);
            //创建ViewModel
            var permissionViews = new List<PermissionViewModel>();

            //var map = Mapper.CreateMap<ApplicationPermission, PermissionViewModel>();
            permissions.Each(t =>
            {
                var view = Mapper.Map<PermissionViewModel>(t);
                view.RoleId = roleId;
                permissionViews.Add(view);
            });
            //排序
            permissionViews.Sort(new PermissionViewModelComparer());
            return View(permissionViews.ToPagedList(index, 10));
        }
开发者ID:Partialsky,项目名称:AspNetIdentityPermission,代码行数:28,代码来源:RolePermissionsController.cs

示例14: Index

        public async Task<ActionResult> Index(int page = 1)
        {
            var orders = await orderRep.Get().OrderByDescending(o => o.OrderDate).ToListAsync();

            var models = new List<OrderViewModel>();

            OrderViewModel model;

            foreach (var o in orders)
            {
                model = new OrderViewModel();
                model.OrderId = o.OrderId;
                model.UserId = o.UserId;
                model.UserName = o.FullName;
                model.PhoneNumber = o.PhoneNumber;
                model.Email = o.Email;
                model.Remark = o.Remark;
                model.OrderDate = o.OrderDate;
                model.Amount = o.Amount;
                model.ShippingTo = o.ShippingTo;
                model.OrderStatus = o.OrderStatus;
                model.ShippingAddress = o.ShippingAddress;
                model.ShippingStatus = o.ShippingStatus;

                models.Add(model);
            }

            return View(models.ToPagedList(page, 10));
        }
开发者ID:oldkwok,项目名称:Kwop,代码行数:29,代码来源:ConsumeAdminController.cs

示例15: Index

        // GET: /Ads/
        public ActionResult Index(int? page)
        {
            if (Authentication.Checklogin())
            {
                int pageSize = 8;
                int pageNum = (page ?? 1);

                var _ListAds = _adsService.GetAllAds();
                var proObj = new List<AdsViewModel>();
                if (_ListAds != null)
                {
                    foreach (var item in _ListAds)
                    {
                        proObj.Add(
                                   new AdsViewModel()
                                   {
                                       AdsId = item.AdsId,
                                       Name = item.Name,
                                       Image = item.Image,
                                       URL = item.URL,
                                       IsShow = item.IsShow == true ? "Có" : "Không"
                                   });
                    }
                }
                ViewBag.Count = proObj.Count;
                var result = proObj.ToPagedList(pageNum, pageSize);
                ViewBag._ListAds = result;
                return View(result);
            }
            else
                return RedirectToAction("Index", "Login");
        }
开发者ID:dattienmdc,项目名称:SHTeam,代码行数:33,代码来源:AdsController.cs


注:本文中的List.ToPagedList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。