private string audit(int id) { Model.BookCommentModel model = bookCommentManager.GetModel(id); model.IsPass = true; if (bookCommentManager.Update(model)) { return("{\"state\":\"ok\",\"measage\":\"审核通过\"}"); } else { return("{\"state\":\"no\",\"measage\":\"更新失败\"}"); } }
private string audit(int id) { Model.BookCommentModel model = bookCommentManager.GetModel(id); model.IsPass = true; if (bookCommentManager.Update(model)) { return("{ok:审核通过}"); } else { return("no:更新失败"); } }
/// <summary> /// 加载评论 /// </summary> /// <param name="context"></param> private void LoadComment(HttpContext context) { Model.BookCommentModel bookComment = new Model.BookCommentModel(); bookComment.BookId = Convert.ToInt32(context.Request["bookId"]); List <Model.BookCommentModel> list = bookCommentManager.GetModelList("IsPass <> 0 AND BookId = " + bookComment.BookId); List <BookCommentViewModel> newList = new List <BookCommentViewModel>(); foreach (var item in list) { ViewModel.BookCommentViewModel viewModel = new BookCommentViewModel(); viewModel.Msg = Common.WebCommon.UbbToHtml(item.Msg); //将UBB编码转换成HTML编码 viewModel.CreateDateTime = Common.WebCommon.GetTimeSpan(System.DateTime.Now - item.CreateDateTime); //获取时间差 newList.Add(viewModel); } System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); context.Response.Write(js.Serialize(newList)); }
protected List <Model.BookCommentModel> fromDsChangeToList(DataSet ds) { List <Model.BookCommentModel> list = new List <Model.BookCommentModel>(); if (ds.Tables["ds"] != null && ds.Tables["ds"].Rows.Count > 0) { foreach (DataRow item in ds.Tables["ds"].Rows) { Model.BookCommentModel bcm = new Model.BookCommentModel(); bcm.Id = Convert.ToInt32(item["Id"]); bcm.Msg = item["Msg"].ToString(); bcm.CreateDateTime = Convert.ToDateTime(item["CreateDateTime"]); bcm.BookId = Convert.ToInt32(item["BookId"]); bcm.IsPass = Convert.ToBoolean(item["IsPass"]); list.Add(bcm); } } return(list); }
/// <summary> /// 添加评论 /// </summary> /// <param name="context"></param> private void AddComment(HttpContext context) { BLL.Articel_WordsBLL articelWordManger = new BLL.Articel_WordsBLL(); string msg = context.Request["msg"]; bool isPass = true; //判断是否含有禁用词 if (articelWordManger.CheckForbid(msg)) { context.Response.Write("no:评论中含有禁用词"); } // 判断是否含有敏感词 if (articelWordManger.CheckMod(msg)) { isPass = false; } Model.BookCommentModel bookComment = new Model.BookCommentModel(); bookComment.BookId = Convert.ToInt32(context.Request["bookId"]); bookComment.Msg = articelWordManger.CheckReplace(msg); bookComment.CreateDateTime = System.DateTime.Now; bookComment.IsPass = isPass; if (bookCommentManager.Add(bookComment) > 0) { if (bookComment.IsPass == true) { context.Response.Write("ok:评论成功"); } else { context.Response.Write("unaudit:评论中含有敏感词,审核后方可显示"); } } else { context.Response.Write("no:评论失败"); } }