コード例 #1
0
ファイル: FriendsService.cs プロジェクト: githexing/05
        //评论动态
        public bool ReviewTrends(long userid, long touserid, long dynamicid, string content, out long commenID, out string message)
        {
            commenID = 0;
            if (ReviewTrendsValidate(userid, dynamicid, content, out message))
            {
                var userModel     = userBLL.GetModel(userid);
                var frienddynamic = friendBLL.GetModel(dynamicid);
                if (userModel == null)
                {
                    message = "用户ID不存在";
                    return(false);
                }
                if (frienddynamic == null)
                {
                    message = "评论用户ID不存在";
                    return(false);
                }

                lgk.Model.tb_FriendDynamicComment friendDynam = new lgk.Model.tb_FriendDynamicComment()
                {
                    UserID    = userid,
                    DynamicID = dynamicid,
                    Content   = content.Trim(),
                    AddTime   = DateTime.Now,
                    ToUserID  = touserid
                };
                commenID = friendDynamicCommenBLL.Add(friendDynam);
                if (commenID > 0)
                {
                    UpdateFriendDynamic("CommentNum", dynamicid, 1, 1);
                    message = "评论成功";
                    return(true);
                }
                else
                {
                    message = "评论失败";
                    return(false);
                }
            }

            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.tb_FriendDynamicComment GetModel(long ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID, UserID, DynamicID, Content, AddTime  ");
            strSql.Append("  from tb_FriendDynamicComment ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;


            lgk.Model.tb_FriendDynamicComment model = new lgk.Model.tb_FriendDynamicComment();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserID"].ToString() != "")
                {
                    model.UserID = long.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DynamicID"].ToString() != "")
                {
                    model.DynamicID = long.Parse(ds.Tables[0].Rows[0]["DynamicID"].ToString());
                }
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lgk.Model.tb_FriendDynamicComment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_FriendDynamicComment set ");

            strSql.Append(" UserID = @UserID , ");
            strSql.Append(" DynamicID = @DynamicID , ");
            strSql.Append(" Content = @Content , ");
            strSql.Append(" AddTime = @AddTime  ");
            strSql.Append(" where ID=@ID ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",        SqlDbType.BigInt,   8),
                new SqlParameter("@UserID",    SqlDbType.BigInt,   8),
                new SqlParameter("@DynamicID", SqlDbType.BigInt,   8),
                new SqlParameter("@Content",   SqlDbType.VarChar, -1),
                new SqlParameter("@AddTime",   SqlDbType.DateTime)
            };

            parameters[0].Value = model.ID;
            parameters[1].Value = model.UserID;
            parameters[2].Value = model.DynamicID;
            parameters[3].Value = model.Content;
            parameters[4].Value = model.AddTime;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(lgk.Model.tb_FriendDynamicComment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_FriendDynamicComment(");
            strSql.Append("UserID,DynamicID,Content,AddTime,ToUserID");
            strSql.Append(") values (");
            strSql.Append("@UserID,@DynamicID,@Content,@AddTime,@ToUserID");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID",    SqlDbType.BigInt,     8),
                new SqlParameter("@DynamicID", SqlDbType.BigInt,     8),
                new SqlParameter("@Content",   SqlDbType.VarChar,   -1),
                new SqlParameter("@AddTime",   SqlDbType.DateTime),
                new SqlParameter("@ToUserID",  SqlDbType.BigInt, 8)
            };

            parameters[0].Value = model.UserID;
            parameters[1].Value = model.DynamicID;
            parameters[2].Value = model.Content;
            parameters[3].Value = model.AddTime;
            parameters[4].Value = model.ToUserID;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }