Beispiel #1
0
 public ActionResult UnFollow(int following_id)
 {
     // userId 指follow对象
     // todo
     if ((User)Session["user"] != null)
     {
         int user_id = ((User)Session["user"]).id;
         FollowDB.Delete(user_id, following_id);
         Notice notice = new Notice(0, user_id, following_id, 0, "unfollow", false, DateTime.Now);
         NoticeDB.Insert(notice);
         return(Json(new { success = 1 }));
     }
     else
     {
         return(Json(new { success = 0 }));
     }
 }
Beispiel #2
0
        public ActionResult Dislike(int weikeId)
        {
            // todo

            if ((User)Session["user"] != null)
            {
                int user_id = ((User)Session["user"]).id;
                FavoriteDB.Delete(user_id, weikeId);
                WeikeData wd     = WeikeDB.FindByWeikeId(weikeId);
                Notice    notice = new Notice(0, user_id, wd.weike.user_id, weikeId, "dislike", false, DateTime.Now);
                NoticeDB.Insert(notice);
                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { success = false, message = "用户尚未登录" }));
            }
        }
Beispiel #3
0
        public ActionResult makeComment(int commentTargetId, string content, int weikeId)
        {
            // todo
            if ((User)Session["user"] != null)
            {
                int    user_id  = ((User)Session["user"]).id;
                string username = ((User)Session["user"]).name;
                if (commentTargetId != 0)
                {
                    Comment parent        = CommentDB.FindCommentById(commentTargetId);
                    int     parent_userId = parent.user_id;
                    if (user_id == parent_userId)
                    {
                        return(Json(new { success = -1 }));
                    }
                    Notice notice = new Notice(0, user_id, parent_userId, weikeId, "reply", false, DateTime.Now);
                    NoticeDB.Insert(notice);
                }
                else
                {
                    int    userId = WeikeDB.FindByWeikeId(weikeId).weike.user_id;
                    Notice notice = new Notice(0, user_id, userId, weikeId, "comment", false, DateTime.Now);
                    NoticeDB.Insert(notice);
                }
                DateTime now        = DateTime.Now;
                Comment  comment    = new Comment(0, user_id, weikeId, now, content, commentTargetId);
                int      comment_id = CommentDB.Insert(comment);
                return(Json(new { success = 1, commentId = comment_id, username = username, time = now }));
            }
            else
            {
                return(Json(new { success = 0 }));
            }

            // id of the new comment
        }