public async Task <MessageModel <PageModel <BlogArticle> > > Query(String bsubmitter, String btitle, String bcategory, Int32 bcommentNum, int Pageindex, int PageSize = 10)
        {
            Expression <Func <BlogArticle, bool> > whereExpressionAll = r => true;

            if (!string.IsNullOrEmpty(bsubmitter))
            {
                whereExpressionAll = whereExpressionAll.And(p => p.bsubmitter == bsubmitter);
            }

            if (!string.IsNullOrEmpty(btitle))
            {
                whereExpressionAll = whereExpressionAll.And(p => p.btitle == btitle);
            }

            if (!string.IsNullOrEmpty(bcategory))
            {
                whereExpressionAll = whereExpressionAll.And(p => p.bcategory == bcategory);
            }

            if ((int)bcommentNum != 0)
            {
                whereExpressionAll = whereExpressionAll.And(p => p.bcommentNum == bcommentNum);
            }

            var data = await _BlogArticleServices.QueryPage(whereExpressionAll, Pageindex, PageSize);

            return(new MessageModel <PageModel <BlogArticle> >(data));
        }
Example #2
0
        public async Task <MessageModel <PageModel <BlogArticle> > > Get(int id, int page = 1, string bcategory = "技术博文",
                                                                         string key       = "")
        {
            int intPageSize = 6;

            if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
            {
                key = "";
            }

            Expression <Func <BlogArticle, bool> > whereExpression = a => (a.bcategory == bcategory && a.IsDeleted == false) && ((a.btitle != null && a.btitle.Contains(key)) || (a.bcontent != null && a.bcontent.Contains(key)));

            var pageModelBlog = await _blogArticleServices.QueryPage(whereExpression, page, intPageSize, " bID desc ");

            return(new MessageModel <PageModel <BlogArticle> >()
            {
                success = true,
                msg = "获取成功",
                response = new PageModel <BlogArticle>()
                {
                    page = page,
                    dataCount = pageModelBlog.dataCount,
                    data = pageModelBlog.data,
                    pageCount = pageModelBlog.pageCount,
                }
            });
        }
        public async Task <MessageModel <PageModel <BlogArticle> > > Get(int page = 1, string key = "", int intPageSize = 50)
        {
            if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
            {
                key = "";
            }

            Expression <Func <BlogArticle, bool> > whereExpression = a => a.bID > 0;

            return(new MessageModel <PageModel <BlogArticle> >()
            {
                msg = "获取成功",
                success = true,
                response = await _blogArticleServices.QueryPage(whereExpression, page, intPageSize)
            });
        }
Example #4
0
        public async Task <MessageModel <PageModel <BlogArticle> > > Get(int id, int page = 1, string bcategory = "技术博文", string key = "")
        {
            int intPageSize = 6;

            if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
            {
                key = "";
            }

            Expression <Func <BlogArticle, bool> > whereExpression = a => (a.bcategory == bcategory && a.IsDeleted == false) && ((a.btitle != null && a.btitle.Contains(key)) || (a.bcontent != null && a.bcontent.Contains(key)));

            var pageModelBlog = await _blogArticleServices.QueryPage(whereExpression, page, intPageSize, " bID desc ");

            using (MiniProfiler.Current.Step("获取成功后,开始处理最终数据"))
            {
                foreach (var item in pageModelBlog.data)
                {
                    if (!string.IsNullOrEmpty(item.bcontent))
                    {
                        item.bRemark = (HtmlHelper.ReplaceHtmlTag(item.bcontent)).Length >= 200 ? (HtmlHelper.ReplaceHtmlTag(item.bcontent)).Substring(0, 200) : (HtmlHelper.ReplaceHtmlTag(item.bcontent));
                        int totalLength = 500;
                        if (item.bcontent.Length > totalLength)
                        {
                            item.bcontent = item.bcontent.Substring(0, totalLength);
                        }
                    }
                }
            }

            return(new MessageModel <PageModel <BlogArticle> >()
            {
                success = true,
                msg = "获取成功",
                response = new PageModel <BlogArticle>()
                {
                    page = page,
                    dataCount = pageModelBlog.dataCount,
                    data = pageModelBlog.data,
                    pageCount = pageModelBlog.pageCount,
                }
            });
        }