Exemplo n.º 1
0
        public JsonResult Delete([FromForm] string token, [FromForm] int commentId)
        {
            DataResult dr = new DataResult();

            try
            {
                if (commentId < 10000)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }

                UserEntity userEntity = this.GetUserByToken(token);

                CommentBLL    commentBLL    = new CommentBLL();
                CommentEntity commentEntity = commentBLL.GetById(commentId);

                if (userEntity.userId != commentEntity.userId)
                {
                    dr.code = "201";
                    dr.msg  = "不是你的评论";
                    return(Json(dr));
                }

                commentEntity.isDel      = true;
                commentEntity.modifyDate = DateTime.Now;
                int rows = commentBLL.ActionDal.ActionDBAccess.Updateable(commentEntity).ExecuteCommand();
                if (rows > 0)
                {
                    dr.code = "200";
                    dr.msg  = "成功";
                }
                else
                {
                    dr.code = "201";
                    dr.msg  = "失败";
                }
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }
            return(Json(dr));
        }