示例#1
0
        public IActionResult GetAdsList(string keyword, int page = 1, int limit = 20, int kid = 0)
        {
            int numPerPage, currentPage, startRowIndex;

            numPerPage    = limit;
            currentPage   = page;
            startRowIndex = (currentPage - 1) * numPerPage;
            Expression ex = Ads._.Id > 0;

            if (kid > 0)
            {
                ex &= Ads._.KId == kid;
            }

            if (!string.IsNullOrWhiteSpace(keyword))
            {
                ex &= Ads._.Title.Contains(keyword);
            }

            IList <Ads> list       = Ads.FindAll(ex, Ads._.Sequence.Asc().And(Ads._.Id.Desc()), null, startRowIndex, numPerPage);
            long        totalCount = Ads.FindCount(ex, Ads._.Sequence.Asc().And(Ads._.Id.Desc()), null, startRowIndex, numPerPage);

            return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain"));
            //return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
        }