/// <summary> /// 删除某条评论 /// </summary> /// <returns></returns> public ActionResult DeleteMsgComment() { base.returnObj = new Return_Msg_APP(); base.returnObj.code = "200"; string appId = Context.GetRequest("appId", string.Empty); int Id = Context.GetRequestInt("Id", 0); if (string.IsNullOrEmpty(appId) || Id <= 0) { base.returnObj.Msg = "参数错误"; return(Json(base.returnObj)); } XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { base.returnObj.Msg = "小程序未授权"; return(Json(base.returnObj)); } CityMsgComment cityMsgComment = CityMsgCommentBLL.SingleModel.GetModel(Id); if (cityMsgComment == null || cityMsgComment.AId != r.Id) { base.returnObj.Msg = "帖子评论不存在"; return(Json(base.returnObj)); } cityMsgComment.State = -1; if (CityMsgCommentBLL.SingleModel.Update(cityMsgComment, "State")) { base.returnObj.isok = true; base.returnObj.Msg = "操作成功"; return(Json(base.returnObj)); } else { base.returnObj.Msg = "操作失败"; return(Json(base.returnObj)); } }
/// <summary> /// 新增评论 /// </summary> /// <returns></returns> public ActionResult AddComment() { base.returnObj = new Return_Msg_APP(); base.returnObj.code = "200"; string appId = Context.GetRequest("appId", string.Empty); int userId = Context.GetRequestInt("userId", 0); int Id = Context.GetRequestInt("Id", 0); string commentDetail = Context.GetRequest("commentDetail", string.Empty); if (string.IsNullOrEmpty(appId) || userId <= 0 || Id <= 0) { base.returnObj.Msg = "参数错误"; return(Json(base.returnObj)); } if (string.IsNullOrEmpty(commentDetail)) { base.returnObj.Msg = "评论详情不能为空"; return(Json(base.returnObj)); } if (commentDetail.Length > 1000) { base.returnObj.Msg = "评论详情最大1000字符"; return(Json(base.returnObj)); } XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { base.returnObj.Msg = "小程序未授权"; return(Json(base.returnObj)); } //表示帖子的评论 CityMsg cityMsg = CityMsgBLL.SingleModel.GetModel(Id); if (cityMsg == null || cityMsg.state == -1) { base.returnObj.Msg = "帖子不存在!"; return(Json(base.returnObj)); } CityMsgComment cityMsgComment = new CityMsgComment(); cityMsgComment.AId = r.Id; cityMsgComment.FromUserId = userId; cityMsgComment.CommentDetail = commentDetail; cityMsgComment.AddTime = DateTime.Now; cityMsgComment.ToUserId = cityMsg.userId; cityMsgComment.MsgId = cityMsg.Id; int commentTotalCount = 0; int commentId = Convert.ToInt32(CityMsgCommentBLL.SingleModel.Add(cityMsgComment)); if (commentId > 0) { base.returnObj.dataObj = new { comments = CityMsgCommentBLL.SingleModel.GetCityMsgComment(r.Id, out commentTotalCount, string.Empty, 1000, 1, cityMsg.Id) }; base.returnObj.isok = true; base.returnObj.Msg = "评论成功"; return(Json(base.returnObj)); } else { base.returnObj.Msg = "评论失败"; return(Json(base.returnObj)); } }