Example #1
0
        public string WriteContent()
        {
            if (null == BLLSession.UserInfoSessioin)
            {
                return(new JSData()
                {
                    Messg = "您还未登录~",
                    State = EnumState.异常或Session超时
                }.ToJson());
            }
            if (BLLSession.UserInfoSessioin.IsLock)
            {
                return(new JSData()
                {
                    Messg = "您的账户已经被锁定,请联系管理员~",
                    State = EnumState.失败
                }.ToJson());
            }
            //|| MySession.UserInfoSessioin.IsLock)
            //    return "no";

            var BlogId      = int.Parse(Request.Form["BlogId"]);
            var UserId      = BLLSession.UserInfoSessioin.Id; //int.Parse(Request.Form["UserId"]);
            var CommentID   = int.Parse(Request.Form["CommentID"]);
            var Content     = Request.Form["Content"];
            var ReplyUserID = int.Parse(Request.Form["ReplyUser"]);

            if (Content.Length >= 1000)
            {
                return(new JSData()
                {
                    State = EnumState.失败
                }.ToJson());
            }

            var ReplyUserName = string.Empty;
            var User          = BLL.Common.CacheData.GetAllUserInfo().Where(t => t.Id == ReplyUserID).FirstOrDefault();

            if (null != User)
            {
                ReplyUserName = string.IsNullOrEmpty(User.UserNickname) ? User.UserName : User.UserNickname;
            }

            BLL.BlogCommentSetBLL comment = new BLL.BlogCommentSetBLL();
            comment.Add(new BlogCommentSet()
            {
                BlogUsersId   = UserId,
                BlogsId       = BlogId,
                Content       = Content,
                CommentID     = CommentID,
                ReplyUserID   = ReplyUserID,
                ReplyUserName = ReplyUserName,
                IsInitial     = CommentID == -1
            });

            BLL.BlogsBLL blogbll  = new BLL.BlogsBLL();
            var          blogmode = blogbll.GetList(t => t.Id == BlogId).FirstOrDefault();

            if (null == blogmode.BlogCommentNum)
            {
                blogmode.BlogCommentNum = comment.GetList(t => t.BlogsId == BlogId).Count() + 1;
            }
            else
            {
                blogmode.BlogCommentNum++;
            }
            blogbll.Up(blogmode, "BlogCommentNum");

            comment.save();

            return(new JSData()
            {
                //这里发表成功    就不提示了。
                State = EnumState.成功
            }.ToJson());
        }
Example #2
0
        public string WriteContent()
        {
            if (null == BLLSession.UserInfoSessioin)
            {
                return new JSData()
                {
                    Messg = "您还未登录~",
                    State = EnumState.异常或Session超时
                }.ToJson();
            }
            if (BLLSession.UserInfoSessioin.IsLock)
            {
                return new JSData()
                {
                    Messg = "您的账户已经被锁定,请联系管理员~",
                    State = EnumState.失败
                }.ToJson();
            }
            //|| MySession.UserInfoSessioin.IsLock)
            //    return "no";

            var BlogId = int.Parse(Request.Form["BlogId"]);
            var UserId = BLLSession.UserInfoSessioin.Id; //int.Parse(Request.Form["UserId"]);
            var CommentID = int.Parse(Request.Form["CommentID"]);
            var Content = Request.Form["Content"];
            var ReplyUserID = int.Parse(Request.Form["ReplyUser"]);

            if (Content.Length >= 1000)
            {
                return new JSData()
                {
                    State = EnumState.失败
                }.ToJson();
            }

            var ReplyUserName = string.Empty;
            var User = BLL.Common.CacheData.GetAllUserInfo().Where(t => t.Id == ReplyUserID).FirstOrDefault();
            if (null != User)
            {
                ReplyUserName = string.IsNullOrEmpty(User.UserNickname) ? User.UserName : User.UserNickname;
            }

            BLL.BlogCommentSetBLL comment = new BLL.BlogCommentSetBLL();
            comment.Add(new BlogCommentSet()
            {
                BlogUsersId = UserId,
                BlogsId = BlogId,
                Content = Content,
                CommentID = CommentID,
                ReplyUserID = ReplyUserID,
                ReplyUserName = ReplyUserName,
                IsInitial = CommentID == -1
            });

            BLL.BlogsBLL blogbll = new BLL.BlogsBLL();
            var blogmode = blogbll.GetList(t => t.Id == BlogId).FirstOrDefault();
            if (null == blogmode.BlogCommentNum)
            {
                blogmode.BlogCommentNum = comment.GetList(t => t.BlogsId == BlogId).Count() + 1;
            }
            else
            {
                blogmode.BlogCommentNum++;
            }
            blogbll.Up(blogmode, "BlogCommentNum");

            comment.save();

            return new JSData()
            {
                //这里发表成功    就不提示了。
                State = EnumState.成功
            }.ToJson();
        }