Ejemplo n.º 1
0
        public ResultAddPostInfo AddPostInfo(QueryAddPostInfo query)
        {
            var result = new ResultAddPostInfo {
                Exception = new MyException()
            };

            try
            {
                var realSsid = new EncryDecry().Md5Decrypt(query.Ssid);
                var arr      = GetSession(realSsid);
                if (arr.Length < 3 || ValidatePostInfo(query) != 0)
                {
                    result.Exception.Exmsg   = "not found 标题或内容超过规定";
                    result.Exception.Success = true;
                    return(result);
                }
                var postInfo = new Tb_PostInfo
                {
                    CreateTime = DateTime.Now,
                    UserId     = arr.GetValue(2).ToString(),
                    Title      = query.Title,
                    PostText   = query.PostText,
                    IsShow     = 1,
                    ViewCount  = 1
                };
                _postInfo.AddPostInfo(postInfo);
                result.Exception.Success = true;
            }
            catch (Exception ex)
            {
                result.Exception.Success = false;
                AppLogger.Error($"{ex.Message} {ex.StackTrace}");
            }
            return(result);
        }
Ejemplo n.º 2
0
        public string AddPostInfo([FromBody] QueryAddPostInfo query)
        {
            query.Ssid = query.Ssid.Substring(1, query.Ssid.Length - 2);
            var json = new UserPostInfo().AddPostInfo(query);

            return(JsonConvert.SerializeObject(json));
        }
Ejemplo n.º 3
0
 private int ValidatePostInfo(QueryAddPostInfo query)
 {
     if (query.Title.Length > 16)
     {
         return(1);
     }
     if (query.PostText.Length > 56)
     {
         return(2);
     }
     return(0);
 }