public ActionResult List(ListModel viewModel) { viewModel.ArticleQueryItem.UnitId = NpcMainWebContext.CurrentUnit.Id; viewModel.ArticleQueryItem.Pagination.PageIndex = PageIndex; var model = _indexAction.InitializeListModel(viewModel.ArticleQueryItem); return View(model); }
public ListModel InitializeListModel(ArticleQueryItem queryItem) { var model = new ListModel(); queryItem.UnitId = NpcMainWebContext.CurrentUnit.Id; model.ArticleQueryItem = queryItem; model.ArticleQueryItem.IsShow = true; model.Articles = _articleRepository.Query(queryItem).ToList(); model.ListTitle = "文章列表"; var categoryId = queryItem.CategoryId ?? queryItem.CategoryIdLike; if (categoryId.HasValue) { var category = _articleCategoryRepository.Find(categoryId.Value); if (category != null) model.ListTitle = category.CategoryName; } model.ArticleQueryItem = queryItem; return model; }