Exemplo n.º 1
0
        public JsonResult Create([FromForm] string token, [FromForm] int objId, [FromForm] string contents, [FromForm] int type)
        {
            DataResult dr = new DataResult();

            try
            {
                if (objId < 10000 || string.IsNullOrWhiteSpace(contents) || type < 1)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }

                UserEntity userEntity = this.GetUserByToken(token);

                CommentBLL commentBLL = new CommentBLL();
                int        rows       = commentBLL.Create(userEntity.userId, type, objId, contents);
                //增加阅读记录
                ReadBLL readBLL = new ReadBLL();
                readBLL.Create(userEntity.userId, type, objId);
                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));
        }