本文整理汇总了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));
}
示例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));
}
}
示例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));
}
示例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));
}
示例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");
}
示例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);
}
示例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");
}
示例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));
}
}
示例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));
}
示例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));
}
示例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");
}
示例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");
}
示例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));
}
示例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));
}
示例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");
}