Esempio n. 1
0
 public ActionResult List()
 {
     var model = new ArticleSearchModel();
     model.SearchCategories.AddRange(
         _categoryService.GetAllCategory().Select(t => new SelectListItem
         {
             Text = t.Name,
             Value = t.Id.ToString(),
         })
     );
     return View(model);
 }
Esempio n. 2
0
        public ActionResult InitDataTable(ArticleSearchModel model)
        {
            var query = _articleService.GetAllArticle(title: model.SearchTitle, categoryId: model.SearchCategoryId, showHidden: true,
                pageIndex: model.iDisplayStart / model.iDisplayLength, pageSize: model.iDisplayLength);

            var filterResult = query.Select(t => new ArticleListModel
            {
                Id = t.Id,
                Title = t.Title,
                Views = t.Views,
                CommentCount = t.CommentCount,
                Published = t.Published,
                CreateDate = WebHelper.ConvertToUserTime(t.CreateDate)
            });

            int sortId = model.iDisplayStart + 1;
            var result = from t in filterResult
                         select new[]
                             {
                                 sortId++.ToString(),
                                 t.Title,
                                 t.CreateDate,
                                 t.Views.ToString(),
                                 t.CommentCount.ToString(),
                                 t.Published.ToString(),
                                 t.Id.ToString(),
                                 t.Id.ToString(),
                             };

            return DataTableJsonResult(model.sEcho, model.iDisplayStart, query.TotalCount, query.TotalCount, result);
        }