本文整理汇总了C#中Orchard.UI.Navigation.Pager类的典型用法代码示例。如果您正苦于以下问题:C# Pager类的具体用法?C# Pager怎么用?C# Pager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pager类属于Orchard.UI.Navigation命名空间,在下文中一共展示了Pager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Post
public object Post(string id, ListQueryModel model) {
if (string.IsNullOrEmpty(id)) {
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest));
}
var part = GetProjectionPartRecord(model.ViewId);
if (part == null) {
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest));
}
var pluralService = PluralizationService.CreateService(new CultureInfo("en-US"));
id = pluralService.Singularize(id);
string filterDescription = null;
return GetFilteredRecords(id, part, out filterDescription, model, p => {
_gridService.GenerateSortCriteria(id, model.Sidx, model.Sord, p.Record.QueryPartRecord.Id);
var totalRecords = _projectionManager.GetCount(p.Record.QueryPartRecord.Id);
var pageSize = model.Rows;
var totalPages = (int) Math.Ceiling((float) totalRecords/(float) pageSize);
var pager = new Pager(Services.WorkContext.CurrentSite, model.Page, pageSize);
var records = GetLayoutComponents(p, pager.GetStartIndex(), pager.PageSize);
return new {
totalPages = totalPages,
page = model.Page,
totalRecords = totalRecords,
rows = records,
filterDescription = filterDescription
};
});
}
示例2: FindVideo
public VideoPickerViewModel FindVideo(VideoPickerViewModel model, PagerParameters pagerParameters)
{
var find = model.Find ?? "";
var mediaItemQuery = _orchardServices.ContentManager
.HqlQuery()
.ForPart<MediaItemPart>()
.ForVersion(VersionOptions.Published)
.List()
.Where(m => find == ""
|| m.Title.ToLowerInvariant().Contains(find)
|| m.Filename.ToLowerInvariant().Contains(find)
|| m.MimeType.ToLowerInvariant().Contains(find))
.OrderBy(m => m.Title);
var count = mediaItemQuery.Count();
// when is selected the option 'Show All' in pagination,the page size parameter is equal to 0
if (pagerParameters.PageSize == 0)
{
// assign at page size parameter value the total number of records found
pagerParameters.PageSize = count;
}
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
dynamic shape = _shapeFactory;
model = new VideoPickerViewModel
{
Find = find,
Pager = shape.Pager(pager).TotalItemCount(count),
SearchResult = mediaItemQuery.Select(x => new MediaItemViewModel
{
Title = x.Title,
Description = x.Description,
Filename = x.Filename,
Published = x.Published,
Type = x.Type,
Url = x.Url,
MimeType = x.MimeType,
Id = x.Id,
Size = x.Size,
DefaultThumbnailUrl = x.DefaultThumbnailUrl,
HasEncodedMedia = _encodedMediaRepository.Table.Any(encoded => encoded.MediaItem.Id == x.Id && encoded.EncodingPreset.MediaType == MediaType.Video),
Modified = x.ModifiedUtc,
Created = x.CreatedUtc,
Owner = x.Owner
}).Skip((pager.Page - 1) * pager.PageSize).Take(pager.PageSize == 0 ? count : pager.PageSize).ToList()
};
return model;
}
示例3: List
public List<PatrocinadorRecord> List(PagerParameters pagerParameters, bool? status, string pesquisaLivre)
{
// The pager is used to apply paging on the query and to create a PagerShape
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize);
IQueryable<PatrocinadorRecord> records = _repository.Table;
if (!string.IsNullOrEmpty(pesquisaLivre))
{
records = records.Where(p => p.Nome.Contains(pesquisaLivre) || p.ContactoNome.Contains(pesquisaLivre) || p.ContactoTelefone.Contains(pesquisaLivre) || p.ContactoEmail.Contains(pesquisaLivre));
}
// Apply paging
records = records.Skip(pager.GetStartIndex()).Take(pager.PageSize);
// Construct a Pager shape
var pagerShape = _shapeFactory.Pager(pager).TotalItemCount(records.Count());
return records.ToList();
}
示例4: GetAllItems
public ArticleItemListViewModel GetAllItems(ArticleItemListViewModel model, int issueId, PagerParameters pagerParameters)
{
var find = model.Find ?? "";
var articleItemQuery = _orchardServices.ContentManager
.Query()
.ForVersion(VersionOptions.Latest)
.Join<CommonPartRecord>()
.Where(x => x.Container != null && x.Container.Id == issueId)
.ForPart<ArticlePart>().List()
.Where(x => x.Title.ToLowerInvariant().Contains(find));
var count = articleItemQuery.Count();
// when is selected the option 'Show All' in pagination,the page size parameter is equal to 0
if (pagerParameters.PageSize == 0)
{
// assign at page size parameter value the total number of records found
pagerParameters.PageSize = count;
}
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
dynamic shape = _shapeFactory;
model = new ArticleItemListViewModel
{
IssueId = issueId,
Pager = shape.Pager(pager).TotalItemCount(count),
ArticleItems = articleItemQuery.Select(x => new ArticleItemViewModel
{
Title = x.As<TitlePart>().Title,
Content = x.As<BodyPart>().Text,
Published = x.IsPublished(),
CreatedUtc = x.As<CommonPart>().CreatedUtc,
ModifiedUtc = x.As<CommonPart>().ModifiedUtc,
Author = x.Author,
Id = x.Id
}).Skip((pager.Page - 1) * pager.PageSize).Take(pager.PageSize == 0 ? count : pager.PageSize)
};
return model;
}
示例5: GetAllItems
public PublicationItemListViewModel GetAllItems(PublicationItemListViewModel model, PagerParameters pagerParameters)
{
var find = model.Find ?? "";
var publicationItemQuery = _orchardServices.ContentManager.HqlQuery().ForPart<PublicationPart>()
.ForType(Constants.Publication)
.ForVersion(VersionOptions.Latest)
.List()
.Where(m => find == ""
|| m.Title.ToLowerInvariant().Contains(find));
var count = publicationItemQuery.Count();
// when is selected the option 'Show All' in pagination,the page size parameter is equal to 0
if (pagerParameters.PageSize == 0)
{
// assign at page size parameter value the total number of records found
pagerParameters.PageSize = count;
}
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
dynamic shape = _shapeFactory;
model = new PublicationItemListViewModel
{
Find = find,
Pager = shape.Pager(pager).TotalItemCount(count),
PublicationItems = publicationItemQuery.Select(x => new PublicationItemViewModel
{
Title = x.Title,
Content = x.Text,
Published = x.IsPublished(),
CreatedUtc = x.CreatedUtc,
ModifiedUtc = x.ModifiedUtc,
Id = x.Id
}).Skip((pager.Page - 1) * pager.PageSize).Take(pager.PageSize == 0 ? count:pager.PageSize).ToList()
};
return model;
}
示例6: GetFilteredNotificationBatches
public IEnumerable<ContentItem> GetFilteredNotificationBatches(string keywords, DateTime? fromDate, DateTime? toDate, NotificationBatchSortBy sortBy)
{
var pager = new Pager(_siteService.GetSiteSettings(), new PagerParameters());
var searchSettingsPart = _orchardServices.WorkContext.CurrentSite.As<SearchSettingsPart>();
IEnumerable<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
searchHits = _searchService.Query(keywords, pager.Page, pager.PageSize,
_orchardServices.WorkContext.CurrentSite.As<SearchSettingsPart>().Record.FilterCulture,
searchSettingsPart.SearchIndex,
searchSettingsPart.SearchedFields,
searchHit => searchHit);
var notificationBatchItems = _contentManager
.Query(VersionOptions.Latest, Constants.NotificationBatchContentType)
.ForContentItems(searchHits.Select(hit => hit.ContentItemId));
if (fromDate != null && toDate != null)
{
notificationBatchItems = notificationBatchItems
.Where<CommonPartRecord>(record => record.CreatedUtc >= fromDate.Value && record.CreatedUtc <= toDate.Value);
}
switch (sortBy)
{
case NotificationBatchSortBy.DateSent: notificationBatchItems = notificationBatchItems
.OrderByDescending<CommonPartRecord>(record => record.PublishedUtc);
break;
case NotificationBatchSortBy.Title: notificationBatchItems = notificationBatchItems
.OrderBy<TitlePartRecord>(record => record.Title);
break;
default:
throw new ArgumentOutOfRangeException("sortBy");
}
return notificationBatchItems.List();
}
示例7: GetEncodedList
public EncodedListViewModel GetEncodedList(int id, PagerParameters pagerParameters)
{
var mediaItemPart = _orchardServices.ContentManager.Get<MediaItemPart>(id, VersionOptions.Latest);
if (mediaItemPart == null) {
throw new Exception("Inexistent content");
}
var mediaItemQuery = _encodedMediaRepository.Table.Where(e => e.MediaItem.Id == id).OrderByDescending(e => e.EncodingPreset.Target).ThenByDescending(e => e.EncodingPreset.Id);
var count = mediaItemQuery.Count();
if (pagerParameters.PageSize == 0)
{
pagerParameters.PageSize = count;
}
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
dynamic shape = _shapeFactory;
var model = new EncodedListViewModel {
MediaItemId = mediaItemPart.Id,
Title = mediaItemPart.Title,
Filename = mediaItemPart.Filename,
Pager = shape.Pager(pager).TotalItemCount(count),
EncodedMediaList = mediaItemQuery.Select(x => new EncodedMediaViewModel {
Id = x.Id,
Url = x.Url,
EncodingPreset = (x.EncodingPreset != null) ? x.EncodingPreset.ShortDescription : String.Empty,
Status = x.Status,
Metadata = x.Metadata,
JobErrorMessage = x.JobErrorMessage,
CreatedUtc = x.CreatedUtc,
ModifiedUtc = x.ModifiedUtc,
Owner = x.Owner,
PresetWidth = x.Width,
MediaTarget = (x.EncodingPreset != null) ? x.EncodingPreset.Target : MediaTarget.Unknown,
}).Skip((pager.Page - 1) * pager.PageSize).Take(pager.PageSize == 0 ? count : pager.PageSize).ToList()
};
return model;
}
示例8: GetAllItems
public MediaItemListViewModel GetAllItems(MediaItemListViewModel model, PagerParameters pagerParameters)
{
var find = model.Find ?? "";
var mediaItemQuery = _orchardServices.ContentManager
.Query<MediaItemPart, MediaItemRecord>()
.ForVersion(VersionOptions.Latest)
.List()
.Where(m => find == "" || m.Title.ToLowerInvariant().Contains(find));
var count = mediaItemQuery.Count();
// when is selected the option 'Show All' in pagination,the page size parameter is equal to 0
if (pagerParameters.PageSize == 0)
{
// assign at page size parameter value the total number of records found
pagerParameters.PageSize = count;
}
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
dynamic shape = _shapeFactory;
model = new MediaItemListViewModel {
Pager = shape.Pager(pager).TotalItemCount(count),
MediaItems = mediaItemQuery.Select(x => new MediaItemViewModel {
Title = x.Title,
Description = x.Description,
Filename = x.Filename,
Published = x.Published,
Type = x.Type,
Url = x.Url,
MimeType = x.MimeType,
Id = x.Id,
Size = x.Size,
DefaultThumbnailUrl = x.DefaultThumbnailUrl,
Modified = x.ModifiedUtc,
Created = x.CreatedUtc,
Owner = x.Owner
}).Skip((pager.Page - 1) * pager.PageSize).Take(pager.PageSize == 0 ? count : pager.PageSize).ToList()
};
return model;
}