本文整理汇总了C#中PagedList.Select方法的典型用法代码示例。如果您正苦于以下问题:C# PagedList.Select方法的具体用法?C# PagedList.Select怎么用?C# PagedList.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PagedList
的用法示例。
在下文中一共展示了PagedList.Select方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
//
// GET: /ManagePermissions/
public ActionResult Index()
{
if (!PermissionService.Authorize(PermissionProvider.ManagePermissions))
return AccessDeniedView();
var roles = _unitOfWork.RoleRepository.Get();
ViewBag.Roles = roles;
var permissionRecords = _unitOfWork.PermissionRecordRepository.Get();
var query1 = new PagedList<PermissionRecord>(permissionRecords.ToList(), 0, 100);
PermissionRecordModel model = new PermissionRecordModel();
model.RoleId = roles.FirstOrDefault().Id;
model.PermissionRecord = new GridModel<PermissionRecordModel>
{
Data = query1.Select(g => new PermissionRecordModel()
{
Id = g.Id,
Name = g.Name,
SystemName = g.SystemName,
Category = g.Category,
Allow = g.Roles.Any(x => x.Id == (model.RoleId)),
RoleId = model.RoleId
}),
Total = permissionRecords.Count
};
return View(model);
}
示例2: UsingNavigatorsAjaxPost
public JsonResult UsingNavigatorsAjaxPost(JqGridPost post)
{
var product = new PagedList<Product>(
_productRepository.Table.OrderBy(m => m.ProductID), post.page, post.rows);
var jqRows = product.Select(item => new GridRow
{
Id = item.ProductID.ToString(),
Cell = { item.ProductID, item.Name, item.Size, item.ProductCategory.Name, item.ListPrice }
}).ToList();
var json = product.ToJqGridData(post.page, jqRows);
return Json(json.ToData(), JsonRequestBehavior.AllowGet);
}
示例3: XmlLoadAjaxPost
public ActionResult XmlLoadAjaxPost(JqGridPost post)
{
var products = new PagedList<Product>(
_productRepository.Table.OrderBy(m => m.ProductID), post.page, post.rows);
var jqRows = products.Select(item => new GridRow
{
Id = item.ProductID.ToString(),
Cell = { item.ProductID, item.Name, item.Size, item.ProductCategory.Name, item.ListPrice }
}).ToList();
var json = products.ToJqGridData(post.page, jqRows);
return Content(json.ToData().ToXml(), "text/xml");
}
示例4: OtherInputBoxesJsonData
//ToDo: Add edit delete features with different input boxes
public ActionResult OtherInputBoxesJsonData(JqGridPost post)
{
//var productList = _productRepository.Table.ToList();
using (var ctx = new AdventureWorksLTEntities())
{
var product = new PagedList<Product>(
ctx.Product.OrderBy(m => m.ProductID), post.page, post.rows);
var jqRows = product.Select(item => new GridRow
{
Id = item.ProductID.ToString(),
Cell = {item.ProductID, item.Name, item.Size, item.ProductCategory.Name, item.ListPrice}
}).ToList();
var json = product.ToJqGridData(post.page, jqRows);
return Json(json.ToData(), JsonRequestBehavior.AllowGet);
//return new XmlResult(json);
}
}
示例5: GetExtractedComments
private object GetExtractedComments(PagedList<Comment> replies, int totalReplies)
{
if (totalReplies == 0) return null;
var extractedReplies = replies.Select(x => GetCommentObject(x, replies.TotalCount));
if (replies != null)
return new
{
TotalReplies = totalReplies,
Replies = extractedReplies
};
return null;
}
示例6: GetBestCustomersReport
/// <summary>
/// Get best customers
/// </summary>
/// <param name="createdFromUtc">Order created date from (UTC); null to load all records</param>
/// <param name="createdToUtc">Order created date to (UTC); null to load all records</param>
/// <param name="os">Order status; null to load all records</param>
/// <param name="ps">Order payment status; null to load all records</param>
/// <param name="ss">Order shipment status; null to load all records</param>
/// <param name="orderBy">1 - order by order total, 2 - order by number of orders</param>
/// <param name="pageIndex">Page index</param>
/// <param name="pageSize">Page size</param>
/// <returns>Report</returns>
public virtual IPagedList<BestCustomerReportLine> GetBestCustomersReport(DateTime? createdFromUtc,
DateTime? createdToUtc, OrderStatus? os, PaymentStatus? ps, ShippingStatus? ss, int orderBy,
int pageIndex = 0, int pageSize = 214748364)
{
int? orderStatusId = null;
if (os.HasValue)
orderStatusId = (int)os.Value;
int? paymentStatusId = null;
if (ps.HasValue)
paymentStatusId = (int)ps.Value;
int? shippingStatusId = null;
if (ss.HasValue)
shippingStatusId = (int)ss.Value;
var query1 = from c in _customerRepository.Table
join o in _orderRepository.Table on c.Id equals o.CustomerId
where (!createdFromUtc.HasValue || createdFromUtc.Value <= o.CreatedOnUtc) &&
(!createdToUtc.HasValue || createdToUtc.Value >= o.CreatedOnUtc) &&
(!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) &&
(!paymentStatusId.HasValue || paymentStatusId == o.PaymentStatusId) &&
(!shippingStatusId.HasValue || shippingStatusId == o.ShippingStatusId) &&
(!o.Deleted) &&
(!c.Deleted)
select new { c, o };
var query2 = from co in query1
group co by co.c.Id into g
select new
{
CustomerId = g.Key,
OrderTotal = g.Sum(x => x.o.OrderTotal),
OrderCount = g.Count()
};
switch (orderBy)
{
case 1:
{
query2 = query2.OrderByDescending(x => x.OrderTotal);
}
break;
case 2:
{
query2 = query2.OrderByDescending(x => x.OrderCount);
}
break;
default:
throw new ArgumentException("Wrong orderBy parameter", "orderBy");
}
var tmp = new PagedList<dynamic>(query2, pageIndex, pageSize);
return new PagedList<BestCustomerReportLine>(tmp.Select(x => new BestCustomerReportLine
{
CustomerId = x.CustomerId,
OrderTotal = x.OrderTotal,
OrderCount = x.OrderCount
}),
tmp.PageIndex, tmp.PageSize, tmp.TotalCount);
}
示例7: Search
public ActionResult Search(SearchModel model, SearchPagingFilteringModel command)
{
if (model == null)
model = new SearchModel();
//'Continue shopping' URL
_customerService.SaveCustomerAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.LastContinueShoppingPage, _webHelper.GetThisPageUrl(false));
if (command.PageSize <= 0) command.PageSize = _catalogSettings.SearchPageProductsPerPage;
if (command.PageNumber <= 0) command.PageNumber = 1;
if (model.Q == null)
model.Q = "";
model.Q = model.Q.Trim();
var categories = _categoryService.GetAllCategories();
if (categories.Count > 0)
{
model.AvailableCategories.Add(new SelectListItem()
{
Value = "0",
Text = _localizationService.GetResource("Common.All")
});
foreach(var c in categories)
model.AvailableCategories.Add(new SelectListItem()
{
Value = c.Id.ToString(),
Text = c.GetCategoryBreadCrumb(_categoryService),
Selected = model.Cid == c.Id
});
}
var manufacturers = _manufacturerService.GetAllManufacturers();
if (manufacturers.Count > 0)
{
model.AvailableManufacturers.Add(new SelectListItem()
{
Value = "0",
Text = _localizationService.GetResource("Common.All")
});
foreach (var m in manufacturers)
model.AvailableManufacturers.Add(new SelectListItem()
{
Value = m.Id.ToString(),
Text = m.Name,
Selected = model.Mid == m.Id
});
}
IPagedList<Product> products = new PagedList<Product>(new List<Product>(), 0, 1);
// only search if query string search keyword is set (used to avoid searching or displaying search term min length error message on /search page load)
if (Request.Params["Q"] != null)
{
if (model.Q.Length < _catalogSettings.ProductSearchTermMinimumLength)
{
model.Warning = string.Format(_localizationService.GetResource("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength);
}
else
{
var categoryIds = new List<int>();
int manufacturerId = 0;
decimal? minPriceConverted = null;
decimal? maxPriceConverted = null;
bool searchInDescriptions = false;
if (model.As)
{
//advanced search
var categoryId = model.Cid;
if (categoryId > 0)
{
categoryIds.Add(categoryId);
if (model.Isc)
{
//include subcategories
categoryIds.AddRange(GetChildCategoryIds(categoryId));
}
}
manufacturerId = model.Mid;
//min price
if (!string.IsNullOrEmpty(model.Pf))
{
decimal minPrice = decimal.Zero;
if (decimal.TryParse(model.Pf, out minPrice))
minPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(minPrice, _workContext.WorkingCurrency);
}
//max price
if (!string.IsNullOrEmpty(model.Pt))
{
decimal maxPrice = decimal.Zero;
if (decimal.TryParse(model.Pt, out maxPrice))
maxPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(maxPrice, _workContext.WorkingCurrency);
}
searchInDescriptions = model.Sid;
}
//products
IList<int> filterableSpecificationAttributeOptionIds = null;
products = _productService.SearchProducts(categoryIds, manufacturerId, null,
//.........这里部分代码省略.........
示例8: UpdatePermissionRecord
public ActionResult UpdatePermissionRecord(int id, PermissionRecordModel model)
{
var prs = _unitOfWork.PermissionRecordRepository.GetSingle(x => x.Id == model.Id);
var role = _unitOfWork.RoleRepository.GetSingle(x => x.Id == model.RoleId);
if (model.Allow)
{
if (prs.Roles.FirstOrDefault(x => x.Id == model.RoleId) == null)
{
prs.Roles.Add(role);
_unitOfWork.PermissionRecordRepository.Update(prs);
//DebugChangeTracker(id, _unitOfWork, "UpdatePermissions", "PermissionRecord");
_unitOfWork.Save();
}
}
else
{
if (prs.Roles.FirstOrDefault(x => x.Id == model.RoleId) != null)
{
prs.Roles.Remove(role);
_unitOfWork.PermissionRecordRepository.Update(prs);
//DebugChangeTracker(id, _unitOfWork, "UpdatePermissions", "PermissionRecord");
_unitOfWork.Save();
}
}
IEnumerable<PermissionRecord> permissionRecords = null;
permissionRecords = _unitOfWork.PermissionRecordRepository.Get();
var enumerable = permissionRecords as List<PermissionRecord> ?? permissionRecords.ToList();
var query1 = new PagedList<PermissionRecord>(enumerable.ToList(), 0, 10);
PermissionRecordModel gridModel = new PermissionRecordModel();
gridModel.PermissionRecord = new GridModel<PermissionRecordModel>
{
Data = query1.Select(g => new PermissionRecordModel()
{
Id = g.Id,
Name = g.Name,
SystemName = g.SystemName,
Category = g.Category,
Allow = g.Roles.Any(x => x.Id == role.Id),
RoleId = role.Id
}),
Total = enumerable.Count()
};
return View(new GridModel(gridModel.PermissionRecord.Data));
}
示例9: FetchAndIncludeReplies
private void FetchAndIncludeReplies(CommentDbContext dbContext, PagedList<Comment> parentComments, CommentSearchCondition commentSearchCondition, bool fetchCountOnly)
{
if (parentComments == null || !parentComments.Any()) return;
var parentCommentIds = parentComments.Select(x => x.Id).ToArray();
var childComments = dbContext.Comments.Where(x => parentCommentIds.Contains(x.ParentId));
foreach (var parent in parentComments)
{
if (fetchCountOnly)
{
parent.Replies = childComments.Where(child => child.ParentId == parent.Id).OrderByDescending(p => p.CreatedOn).ToPagedList(true);
}
else
{
parent.Replies = childComments.Where(child => child.ParentId == parent.Id).OrderByDescending(p => p.CreatedOn).ToPagedList(commentSearchCondition.PageNumber, commentSearchCondition.PageSize);
FetchAndIncludeReplies(dbContext, parent.Replies, commentSearchCondition, true);
}
}
}