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


C# Navigation.Pager类代码示例

本文整理汇总了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
                };
            });
        }
开发者ID:wezmag,项目名称:Coevery,代码行数:29,代码来源:EntityController.cs

示例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;
        }
开发者ID:rgardler,项目名称:dpp,代码行数:49,代码来源:VideoService.cs

示例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();
        }
开发者ID:NunoRodrigues,项目名称:Orchard-Patrocinios,代码行数:20,代码来源:PatrocinadoresService.cs

示例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;
        }
开发者ID:rgardler,项目名称:dpp,代码行数:41,代码来源:ArticleService.cs

示例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;
        }
开发者ID:rgardler,项目名称:dpp,代码行数:37,代码来源:PublicationService.cs

示例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();
        }
开发者ID:Lombiq,项目名称:Orchard-User-Notifications,代码行数:37,代码来源:NotificationBatchService.cs

示例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;
        }
开发者ID:rgardler,项目名称:dpp,代码行数:38,代码来源:MediaServicesService.cs

示例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;
        }
开发者ID:rgardler,项目名称:dpp,代码行数:40,代码来源:MediaServicesService.cs


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