Exemplo n.º 1
0
        /// <summary>
        /// 文章分页
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public PagedList <Help> GetList(HelpSearchView searchView, int pageIndex = 1, int pageSize = 20)
        {
            var expression = base.GetFilterEnabled();

            if (!string.IsNullOrEmpty(searchView.Keyword))
            {
                expression = expression.And(t => t.Title.Contains(searchView.Keyword));
                expression = expression.Or(t => t.Description.Contains(searchView.Keyword));
            }
            //expression = expression.And(t => t.CategoryId == 2);
            return(_Respository.GetPagedList(expression, pageIndex, pageSize));
        }
Exemplo n.º 2
0
        public ActionResult GetTreeSelectJson(HelpSearchView searchView)
        {
            var data = _HelpService.GetList(searchView)
                       .Select(u => new TreeSelectModel {
                id = u.Id, text = u.Title
            }).ToList();

            //默认显示未分组
            data.Insert(0, new TreeSelectModel()
            {
                id = "-1", text = "未分组"
            });
            return(Content(data.ToJson()));
        }
Exemplo n.º 3
0
        public ActionResult GetGridJson(HelpSearchView searchView, int page = 1)
        {
            var data = _HelpService.GetHelps(searchView, page, PageSize);

            data.ForEach(da => {
                da.Description = RegexRegular.CheckMathLength(RegexRegular.NoHTML(da.Description), 20);
                //da.HelpCode = EnumCommon.GetDescription((HelpCode)da.HelpCode);
            });
            return(Content(new
            {
                rows = data,
                total = data.PageCount,
                page = data.PageIndex,
                records = data.TotalCount
            }.ToJson()));
        }
Exemplo n.º 4
0
        public PagedList <HelpDetailView> GetHelps(HelpSearchView searchView, int pageIndex, int pageSize)
        {
            var expression = base.GetFilterEnabled();

            if (searchView.HelpCode.HasValue)
            {
                expression = expression.And(t => t.HelpCode == (int)searchView.HelpCode);
            }

            if (!string.IsNullOrEmpty(searchView.Keyword))
            {
                expression = expression.And(t => t.Title.Contains(searchView.Keyword) ||
                                            t.Description.Contains(searchView.Keyword) ||
                                            t.ShortTitle.Contains(searchView.Keyword));
            }

            if (!searchView.Title.IsEmpty())
            {
                expression = expression.And(t => t.Title.Contains(searchView.Title));
            }

            //expression = expression.And(t => t.CategoryId == 2);
            return(_Respository.GetPagedList(
                       u => new HelpDetailView
            {
                Id = u.Id,
                Title = u.Title,
                CoverUrl = u.CoverUrl,
                ShortTitle = u.ShortTitle,
                Description = u.Description,
                Attachment = u.Attachment,
                //CategoryId = u.CategoryId,
                ReadCount = u.ReadCount,
                ResourceUrl = u.ResourceUrl,
                CreatorTime = u.CreatorTime,
                HelpCode = (HelpCode)u.HelpCode
            }
                       , expression, pageIndex, pageSize, o => o.OrderBy(t => t.SortCode)));
        }