本文整理匯總了C#中Orchard.UI.Navigation.PagerParameters類的典型用法代碼示例。如果您正苦於以下問題:C# PagerParameters類的具體用法?C# PagerParameters怎麽用?C# PagerParameters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PagerParameters類屬於Orchard.UI.Navigation命名空間,在下文中一共展示了PagerParameters類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: List
public ActionResult List(ListContentsViewModel model, PagerParameters pagerParameters) {
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var query = _contentManager.Query<ProductPart, ProductPartRecord>(VersionOptions.Latest);
switch (model.Options.OrderBy) {
case ContentsOrder.Modified:
query.OrderByDescending<CommonPartRecord>(cr => cr.ModifiedUtc);
break;
case ContentsOrder.Published:
query.OrderByDescending<CommonPartRecord>(cr => cr.PublishedUtc);
break;
case ContentsOrder.Created:
query.OrderByDescending<CommonPartRecord>(cr => cr.CreatedUtc);
break;
}
var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count());
var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList();
var list = Shape.List();
list.AddRange(pageOfContentItems.Select(ci => _contentManager.BuildDisplay(ci, "SummaryAdmin")));
dynamic viewModel = Shape.ViewModel()
.ContentItems(list)
.Pager(pagerShape)
.Options(model.Options);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)viewModel);
}
示例2: Index
public ActionResult Index(PagerParameters pagerParameters, string q = "") {
var cleanQ = AntiXssEncoder.HtmlEncode(q, true); // ensure the search query is properly encoded to prevent XSS
var searchSettingPart = Services.WorkContext.CurrentSite.As<SearchSettingsPart>();
if (String.IsNullOrEmpty(searchSettingPart.SearchIndex))
{
Services.Notifier.Error(T("Please define a default search index"));
return HttpNotFound();
}
List<string> contentTypes = new List<string>() {
"Event", "Community", "CodeSample",
"PatternsAndPractices", "Podcast", "Resource",
"Solution", "StepPage", "Training", "VideoItem", "Article"
};
var results = new List<ContentTypeResults>();
results = GetSearchResults(cleanQ, pagerParameters, searchSettingPart, contentTypes);
var searchViewModel = new SearchViewModel
{
Query = cleanQ,
FilteredItems = results
};
//todo: deal with page requests beyond result count
return View(searchViewModel);
}
示例3: Item
public ActionResult Item(string blogPath, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var correctedPath = _blogPathConstraint.FindPath(blogPath);
if (correctedPath == null)
return HttpNotFound();
var blogPart = _blogService.Get(correctedPath);
if (blogPart == null)
return HttpNotFound();
// primary action run for a home paged item shall not pass
if (!RouteData.DataTokens.ContainsKey("ParentActionViewContext")
&& blogPart.Id == _routableHomePageProvider.GetHomePageId(_workContextAccessor.GetContext().CurrentSite.HomePage)) {
return HttpNotFound();
}
_feedManager.Register(blogPart);
var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize)
.Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
dynamic blog = _services.ContentManager.BuildDisplay(blogPart);
var list = Shape.List();
list.AddRange(blogPosts);
blog.Content.Add(Shape.Parts_Blogs_BlogPost_List(ContentItems: list), "5");
var totalItemCount = _blogPostService.PostCount(blogPart);
blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");
return new ShapeResult(this, blog);
}
示例4: Index
public ActionResult Index(PagerParameters pagerParameters, AuditTrailOrderBy? orderBy = null) {
if (!_authorizer.Authorize(Permissions.ViewAuditTrail))
return new HttpUnauthorizedResult();
var viewModel = SetupViewModel(new RecycleBinViewModel(), pagerParameters);
return View(viewModel);
}
示例5: MyPackages
public ActionResult MyPackages(PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
IUser authenticatedUser = _authenticationService.GetAuthenticatedUser();
var key = _userkeyService.GetAccessKeyForUser(authenticatedUser.Id);
dynamic list = _services.New.List();
int startingPackageIndex = pager.GetStartIndex();
IEnumerable<PackagePart> packages = GetPublishedPackagesUserCanManage(authenticatedUser, key, startingPackageIndex, pager.PageSize);
int totalPackageCount = GetCountOfPublishedPackagesUserCanManage(authenticatedUser, key);
IEnumerable<PackagePart> unpublishedPackages = GetUnpublishedPackagesUserCanManage(authenticatedUser, key);
list.AddRange(packages.Select(p => {
dynamic packageShape = _services.ContentManager.BuildDisplay(p, "SummaryOwner");
packageShape.HasTags = p.As<TagsPart>().CurrentTags.Count() > 0;
return packageShape;
}
));
var viewModel = new MyPackagesViewModel {
Packages = list,
TotalNumberOfPackages = totalPackageCount,
StartingNumber = startingPackageIndex + 1,
EndingNumber = totalPackageCount < startingPackageIndex + pager.PageSize ? totalPackageCount : startingPackageIndex + pager.PageSize,
Pager = Shape.Pager(pager).TotalItemCount(totalPackageCount),
UnpublishedPackages = unpublishedPackages
};
return View(viewModel);
}
示例6: Index
public ActionResult Index(int? countryId, PagerParameters pagerParameters)
{
var viewModel = new DeliverySettingsViewModel
{
CountryId = countryId,
CountryRepository = _countryRepository
};
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize);
//var setting = _deliverySettingsRepository.Table.Where(s => s.DeliveryCulture == cultureUsed);
//if (setting.FirstOrDefault() == null)
// {
// _deliverySettingService.AddSetting("Default", 0, 0, 1, cultureUsed);
// }
var allCountrySettings = _deliverySettingsRepository.Table.Where(s => s.Country.Id == (countryId ?? 0));
viewModel.DeliverySettings = allCountrySettings
.OrderBy(a => a.State)
.Skip(pager.GetStartIndex())
.Take(pager.PageSize);
var pagerShape = Shape.Pager(pager).TotalItemCount(allCountrySettings.Count());
viewModel.Pager = pagerShape;
return View(viewModel);
}
示例7: Item
public ActionResult Item(string TimetableSlug, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var correctedSlug = _TimetableSlugConstraint.FindSlug(TimetableSlug);
if (correctedSlug == null)
return HttpNotFound();
var TimetablePart = _TimetableService.Get(correctedSlug);
if (TimetablePart == null)
return HttpNotFound();
if (!RouteData.DataTokens.ContainsKey("ParentActionViewContext")
&& TimetablePart.Id == _routableHomePageProvider.GetHomePageId(_workContextAccessor.GetContext().CurrentSite.HomePage)) {
return HttpNotFound();
}
_feedManager.Register(TimetablePart);
var TimetableAppointments = _TimetableAppointmentService.Get(TimetablePart, pager.GetStartIndex(), pager.PageSize)
//.Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
.Select(b => b);
dynamic Timetable = _services.ContentManager.BuildDisplay(TimetablePart);
var list = Shape.List();
list.AddRange(TimetableAppointments);
Timetable.Content.Add(Shape.Parts_Timetables_TimetableAppointment_List(ContentItems: list), "5");
var totalItemCount = _TimetableAppointmentService.AppointmentCount(TimetablePart);
Timetable.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");
return View((object)Timetable);
}
示例8: Item
public ActionResult Item(int blogId, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var blogPart = _blogService.Get(blogId, VersionOptions.Published).As<BlogPart>();
if (blogPart == null)
return HttpNotFound();
if (!_services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent, blogPart, T("Cannot view content"))) {
return new HttpUnauthorizedResult();
}
_feedManager.Register(blogPart, _services.ContentManager.GetItemMetadata(blogPart).DisplayText);
var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize)
.Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
dynamic blog = _services.ContentManager.BuildDisplay(blogPart);
var list = Shape.List();
list.AddRange(blogPosts);
blog.Content.Add(Shape.Parts_Blogs_BlogPost_List(ContentItems: list), "5");
var totalItemCount = _blogPostService.PostCount(blogPart);
blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");
return new ShapeResult(this, blog);
}
示例9: EditCategory
public ActionResult EditCategory(PagerParameters pagerParameters, int id, string searchString)
{
var camps = _campCategService.GetCampaignsByIdCategory(id).ToList();
CampaignCategoriesRecord category = _campCategService.GetCategoryById(id);
if (!string.IsNullOrEmpty(searchString))
{
camps = camps.Where(c => c.Title.ToLower().Contains(searchString.ToLower())).OrderByDescending(c => c.ProductCountSold).OrderBy(c => c.Title).ToList();
}
var entriesProjection = camps.Select(e =>
{
return Shape.FaqEntry(
Id: e.Id,
Title: e.Title,
ProductCountSold: e.ProductCountSold,
ProductCountGoal: e.ProductCountGoal
);
});
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize);
var entries = entriesProjection.Skip(pager.GetStartIndex()).Take(pager.PageSize);
var pagerShape = Shape.Pager(pager).TotalItemCount(entriesProjection.Count());
return View("EditCategory", new AdminSearchViewModel { Camapigns = entries.ToArray(), CategoryId = id, CategoryName = category.Name, Pager = pagerShape });
}
示例10: ShowFormResults
public ActionResult ShowFormResults(int id, PagerParameters pagerParameters)
{
if (!_services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to view form results")))
return new HttpUnauthorizedResult();
var form = _services.ContentManager.Get<OFormPart>(id, VersionOptions.Latest);
if (form == null)
return HttpNotFound();
CheckValidSerial();
var pager = new Pager(_services.WorkContext.CurrentSite, pagerParameters);
var formResults = _resultsRepo.Table.Where(x => x.OFormPartRecord == form.Record);
var pagerShape = Shape.Pager(pager).TotalItemCount(formResults.Count());
var results = formResults
.OrderByDescending(x => x.CreatedDate)
.Skip(pager.GetStartIndex()).Take(pager.PageSize);
return View(new FormResultViewModel
{
FormId = form.Id,
FormName = form.Name,
Results = results.ToList(),
Pager = pagerShape
});
}
示例11: Search
public ActionResult Search(string tagName, PagerParameters pagerParameters)
{
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var tag = _tagService.GetTagByName(tagName);
if (tag == null) {
return RedirectToAction("Index");
}
var taggedItems = _tagService.GetTaggedContentItems(tag.Id, pager.GetStartIndex(), pager.PageSize)
.Select(item => _contentManager.BuildDisplay(item, "Summary"));
var list = _shapeFactory.List();
list.AddRange(taggedItems);
var totalItemCount = _tagService.GetTaggedContentItemCount(tag.Id);
var viewModel = new TagsSearchViewModel {
TagName = tag.TagName,
List = list,
Pager = _shapeFactory.Pager(pager).TotalItemCount(totalItemCount)
};
return View(viewModel);
}
示例12: Item
public ActionResult Item(int forumId, PagerParameters pagerParameters) {
var forumPart = _forumService.Get(forumId, VersionOptions.Published);
if (forumPart == null)
return HttpNotFound();
if (!_orchardServices.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent, forumPart, T("Not allowed to view forum")))
return new HttpUnauthorizedResult();
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var threads = _threadService
.Get(forumPart, pager.GetStartIndex(), pager.PageSize, VersionOptions.Published)
.Select(b => _orchardServices.ContentManager.BuildDisplay(b, "Summary"));
dynamic forum = _orchardServices.ContentManager.BuildDisplay(forumPart);
var list = Shape.List();
list.AddRange(threads);
forum.Content.Add(Shape.Parts_Forums_Thread_List(ContentPart: forumPart, ContentItems: list), "5");
var totalItemCount = forumPart.ThreadCount;
forum.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");
return new ShapeResult(this, forum);
}
示例13: ExecuteAction
public ActionResult ExecuteAction(RecycleBinViewModel viewModel, PagerParameters pagerParameters) {
if (viewModel.RecycleBinCommand == null) {
ModelState.AddModelError("RecycleBinCommand", T("Please select an action to execute.").Text);
}
if (viewModel.SelectedContentItems == null || !viewModel.SelectedContentItems.Any()) {
ModelState.AddModelError("SelectedContentItems", T("Please select one or more content items.").Text);
}
if (!ModelState.IsValid) {
SetupViewModel(viewModel, pagerParameters);
return View("Index", viewModel);
}
if (ModelState.IsValid) {
var selectedContentItemIds = viewModel.SelectedContentItems.Where(x => x.Selected).Select(x => x.Id).ToArray();
switch (viewModel.RecycleBinCommand) {
case RecycleBinCommand.Restore:
RestoreContentItems(selectedContentItemIds);
break;
case RecycleBinCommand.Destroy:
DeleteContentItems(selectedContentItemIds);
break;
}
}
return RedirectToAction("Index");
}
示例14: Index
public ActionResult Index(PagerParameters pagerParameters, string type = "Module", string q = "", string s = "") {
var pager = new Pager(_orchardService.WorkContext.CurrentSite, pagerParameters);
var searchBuilder = GetSearchBuilder();
if (!String.IsNullOrWhiteSpace(q)) {
foreach (var field in new[] { "body", "title", "tags", "package-id" }) {
searchBuilder.Parse(
defaultField: field,
query: q,
escape: true
).AsFilter();
}
}
searchBuilder.WithField("package-extension-type", type.ToLowerInvariant()).NotAnalyzed().ExactMatch();
// Only apply custom order if there is no search filter. Otherwise some oddly related packages
// might appear at the top.
if (String.IsNullOrWhiteSpace(q) && !String.IsNullOrWhiteSpace(s)) {
switch (s) {
case "download":
searchBuilder.SortByInteger("package-download-count");
break;
default:
// Order by relevance by default.
break;
}
}
else if(String.IsNullOrWhiteSpace(q) && String.IsNullOrWhiteSpace(s)) {
searchBuilder.SortByInteger("package-download-count");
}
var count = searchBuilder.Count();
var pageOfResults = searchBuilder.Slice((pager.Page - 1) * pager.PageSize, pager.PageSize).Search();
var list = _orchardService.New.List();
var foundIds = pageOfResults.Select(searchHit => searchHit.ContentItemId).ToList();
var foundItems = _orchardService.ContentManager.GetMany<IContent>(foundIds, VersionOptions.Published, new QueryHints()).ToList();
foreach (var contentItem in foundItems) {
list.Add(_orchardService.ContentManager.BuildDisplay(contentItem, "Summary"));
}
var pagerShape = _orchardService.New.Pager(pager).TotalItemCount(count);
var searchViewModel = _orchardService.New.ViewModel(
Query: q,
TotalItemCount: count,
StartPosition: (pager.Page - 1) * pager.PageSize + 1,
EndPosition: pager.Page * pager.PageSize > count ? count : pager.Page * pager.PageSize,
ContentItems: list,
Pager: pagerShape,
Type: type
);
return View(searchViewModel);
}
示例15: List
public ActionResult List(string packageType, PagerParameters pagerParameters) {
var viewModel = BuildList(string.Empty, packageType, string.Empty, pagerParameters, SORT_BY_DOWNLOAD_COUNT);
if (viewModel == null) {
throw new HttpException(404, "");
}
viewModel.SearchTarget = packageType;
return View(viewModel);
}