Exemplo n.º 1
0
        public void WriterPost(int userid, int boardid, string username, string title, string content, int limitedid)
        {
            if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(content))
            {
                throw new UserException("标题或者内容为空");
            }
            //构造兑现
            ForumPost post = new ForumPost();

            post.Title           = title;
            post.Content         = content;
            post.UserId          = userid;
            post.Like            = 0;
            post.UnLike          = 0;
            post.BoardId         = boardid;
            post.LimitedMemberId = limitedid;
            post.DateLine        = DateTime.Now;
            post.DelFlag         = DelFlag.Normal;
            object obj = DbSession.PostDal.AddPost(post);

            if (obj == null || Convert.ToInt32(obj) == -1)
            {
                throw new UserException("增加用户帖子数据失败");
            }
            //记录发帖操作
            int operationid = Convert.ToInt32(obj);

            //记录好友操作记录
            AddFriendOperation.Add(DbSession, userid, operationid);
        }
Exemplo n.º 2
0
        //依赖注入

        public void AddLikePost(int postid, int userid, string username)
        {
            if (string.IsNullOrEmpty(username))
            {
                throw new UserException("用户名为空");
            }
            LikePost lp = new LikePost();

            lp.PostId     = postid;
            lp.UserLikeId = userid;
            lp.DateLine   = DateTime.Now;
            lp.Looked     = UserLooked.UnLooked;
            object obj = DbSession.LikePostDal.AddLikePost(lp);

            if (null == obj)
            {
                throw new UserException("添加点赞帖子数据失败");
            }
            int useroperationid = Convert.ToInt32(obj);

            //记录好友操作
            AddFriendOperation.Add(DbSession, userid, useroperationid);
        }