public IActionResult GetGuesbookList(string keyword, int page = 1, int limit = 20) { int numPerPage, currentPage, startRowIndex; numPerPage = limit; currentPage = page; startRowIndex = (currentPage - 1) * numPerPage; Expression ex = Guestbook._.Id > 0; if (!string.IsNullOrWhiteSpace(keyword)) { if (Utils.IsInt(keyword)) { ex &= (Guestbook._.Id == int.Parse(keyword) | Guestbook._.Title.Contains(keyword)); } else { ex &= Guestbook._.Title.Contains(keyword); } } string kid = Request.Query["kid"]; if (Utils.IsInt(kid) && int.Parse(kid) > 0) { ex &= Guestbook._.KId == int.Parse(kid); } IList <Guestbook> list = Guestbook.FindAll(ex, Guestbook._.Id.Desc(), null, startRowIndex, numPerPage); long totalCount = Guestbook.FindCount(ex, Guestbook._.Id.Desc(), null, startRowIndex, numPerPage); Core.Admin.WriteLogActions("查看留言列表(page:" + page + ");"); return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain")); }
public JsonResult DelGuestbookCategory(int id) { GuestbookCategory entity = GuestbookCategory.Find(GuestbookCategory._.Id == id); if (entity == null) { tip.Message = "系统找不到本留言分类!"; return(Json(tip)); } //删除栏目下所有留言 IList <Guestbook> list = Guestbook.FindAll(Guestbook._.KId == entity.Id, null, null, 0, 0); if (list != null && list.Count > 0) { list.Delete(); } Core.Admin.WriteLogActions("删除留言分类(id:" + entity.Id + ");"); entity.Delete(); tip.Status = JsonTip.SUCCESS; tip.Message = "删除留言分类成功"; return(Json(tip)); }