Beispiel #1
0
        public ActionResult FilterNotificationBatches(NotificationBatchListViewModel viewModel)
        {
            if (!_orchardServices.Authorizer.Authorize(Permissions.ManageNotifications))
            {
                return(new HttpUnauthorizedResult(T("You are not allowed to manage notifications.").Text));
            }

            var notificationBatchItems = _notificationBatchService.GetFilteredNotificationBatches(viewModel.Keywords, viewModel.FromDate, viewModel.ToDate, viewModel.NotificationBatchSortBy);

            return(GetNotificationBatchListViewResult(notificationBatchItems));
        }
Beispiel #2
0
        private ActionResult GetNotificationBatchListViewResult(IEnumerable <ContentItem> notificationBatchItems, int page = 1, int pageSize = DefaultPageSizeForNotificationBatchList)
        {
            var viewModel = new NotificationBatchListViewModel();

            if (notificationBatchItems.Any())
            {
                var pager = new Pager(_orchardServices.WorkContext.CurrentSite, new PagerParameters {
                    Page = page, PageSize = pageSize
                });

                dynamic pagerShape = _orchardServices.New.Pager(pager).TotalItemCount(notificationBatchItems.Count());

                var notificationBatchShapeList = _orchardServices.New.List();
                notificationBatchShapeList.AddRange(notificationBatchItems
                                                    .Skip(pager.GetStartIndex())
                                                    .Take(pager.PageSize)
                                                    .Select(item => _contentManager.BuildDisplay(item, "SummaryAdmin")));

                viewModel.NotificationBatchShapes = notificationBatchShapeList;
                viewModel.Pager = pagerShape;
            }

            return(View("Index", viewModel));
        }