Beispiel #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);
        }
Beispiel #2
0
        public void AddPostInfo(Tb_PostInfo info)
        {
            var db = new MySqlContext();

            db.TbPostInfos.Add(info);
            db.SaveChanges();
        }