Example #1
0
        // GET: Reply
        public ActionResult AddReplyAction(int replyOfPost, string replyUser, string content, int hasPicture, string picturePath)
        {
            if (Request.Cookies["LoginUser"] == null)
            {
                return(Json("您未登录"));
            }

            content = SensitiveWordFilter.CheckValidity(content);

            ReplyDataAccess rda   = new ReplyDataAccess();
            Reply           reply = new Reply();

            reply.ReplyOfPost = replyOfPost;
            reply.ReplyUser   = replyUser;
            reply.ReplyTime   = DateTime.Now;
            new PostDataAccess().SetReplyCount(replyOfPost);
            int floor = new PostDataAccess().GetPostByID(replyOfPost).ReplyCount;

            reply.ReplyFloor   = floor + 1;
            reply.ReplyContent = content;
            reply.HasPicture   = hasPicture;
            reply.PicturePath  = picturePath;

            bool addresult = rda.AddReply(reply);

            if (addresult)
            {
                new LogDataAccess().AddLog(replyUser, new UserDataAccess().GetUserByID(replyUser).NickName, "回复了《" + new PostDataAccess().GetPostByID(replyOfPost).Title + "》");
                return(Json("success"));
            }
            else
            {
                return(Json("failed"));
            }
        }
Example #2
0
 public ActionResult PublishPost(int communityID, string title, string content, string postUserID, int hasPicture, string picPath)
 {
     if (postUserID == "")
     {
         return(Json("nouser"));
     }
     else
     {
         title   = SensitiveWordFilter.CheckValidity(title);
         content = SensitiveWordFilter.CheckValidity(content);
         Post           post       = new Post(communityID, title, content, postUserID, hasPicture, picPath);
         PostDataAccess pda        = new PostDataAccess();
         bool           addsuccess = pda.AddPost(post);
         if (addsuccess)
         {
             new LogDataAccess().AddLog(postUserID, new UserDataAccess().GetUserByID(postUserID).NickName, "发表了帖子,标题:" + title);
             return(Json("success"));
         }
         else
         {
             return(Json("error"));
         }
     }
 }