public IActionResult GetBlogList(BlogModel model, int pageIndex, int pageSize) { DateTime date = default(DateTime); string where = ""; if (!string.IsNullOrEmpty(model.Title)) { model.Title = Tool.GetSafeSQL(model.Title); where += $" and Title like '%{model.Title}%'"; } if (date != model.StartTime) { where += $" and CreateDate>={model.StartTime.ToString("yyyy-MM-dd")}"; } if (model.EndTime != date) { where += $" and CreateDate<={model.EndTime.ToString("yyyy-MM-dd")}"; } if (!string.IsNullOrEmpty(model.CBh) && model.CBh != "0") { model.CBh = Tool.GetSafeSQL(model.CBh); where += $" and CBh='{model.CBh}'"; } int Count = BlogDAL.GetCount(where); int PageIndex = (pageIndex - 1) * pageSize; where += $" limit {PageIndex},{pageSize}"; var List = BlogDAL.GetBlogList(where); ArrayList arr = new ArrayList(); foreach (var item in List) { arr.Add(new { bId = item.Bid, title = item.Title, createDate = item.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), viewNums = item.ViewNums, cName = item.CName }); } int pageCount = Count % pageSize == 0 ? Count / pageSize : Count / pageSize + 1; return(Json(new { data = arr, pageCount = pageCount, total = Count })); }
public IActionResult GetBlogListTotal() { var Total = _BlogDAL.GetCount(); return(Content(Total.ToString())); }