所以我编写了一个简单的模块,并通过 AdminMenu 显示特定 ContentItems 的列表。除了寻呼机外,一切都很好。寻呼机显示所有ContentItems 的计数,而不是过滤列表。我敢肯定,我错过了一些简单的事情,但我无法弄清楚。
这是我的控制器代码:
public ActionResult List(ListContentsViewModel model, PagerParameters pagerParameters) {
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var query = _contentManager.Query<EventPart>(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);
}
我究竟做错了什么?
谢谢!