コード例 #1
0
 /// <summary>
 /// Inserts a new comment
 /// </summary>
 public override int InsertComment(CommentDetails comment)
 {
     using (SqlConnection cn = new SqlConnection(this.ConnectionString))
     {
         SqlCommand cmd = new SqlCommand("wa_Articles_InsertComment", cn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = comment.AddedDate;
         cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = comment.AddedBy;
         cmd.Parameters.Add("@AddedByEmail", SqlDbType.NVarChar).Value = comment.AddedByEmail;
         cmd.Parameters.Add("@AddedByIP", SqlDbType.NVarChar).Value = comment.AddedByIP;
         cmd.Parameters.Add("@ArticleID", SqlDbType.Int).Value = comment.ArticleID;
         cmd.Parameters.Add("@Body", SqlDbType.NVarChar).Value = comment.Body;
         cmd.Parameters.Add("@CommentID", SqlDbType.Int).Direction = ParameterDirection.Output;
         cn.Open();
         int ret = ExecuteNonQuery(cmd);
         return (int)cmd.Parameters["@CommentID"].Value;
     }
 }
コード例 #2
0
 /// <summary>
 /// Updates an comment
 /// </summary>
 public override bool UpdateComment(CommentDetails comment)
 {
     using (SqlConnection cn = new SqlConnection(this.ConnectionString))
     {
         SqlCommand cmd = new SqlCommand("wa_Articles_UpdateComment", cn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@CommentID", SqlDbType.Int).Value = comment.ID;
         cmd.Parameters.Add("@Body", SqlDbType.NVarChar).Value = comment.Body;
         cn.Open();
         int ret = ExecuteNonQuery(cmd);
         return (ret == 1);
     }
 }
コード例 #3
0
 protected virtual CommentDetails GetCommentFromReader(IDataReader reader)
 {
     CommentDetails comment = new CommentDetails(
         (int)reader["CommentID"],
         (DateTime)reader["AddedDate"],
         reader["AddedBy"].ToString(),
         reader["AddedByEmail"].ToString(),
         reader["AddedbyIP"].ToString(),
         0,
         0,
         "",
         reader["Body"].ToString());
     if (reader["ArticleID"] != DBNull.Value)
     {
         comment.ArticleID = (int)reader["ArticleID"];
         comment.TargetTitle = reader["ArticleTitle"].ToString();
     }
     else
     {
         comment.ProgramID = (int)reader["ProgramID"];
         comment.TargetTitle = reader["ProgramTitle"].ToString();
     }
     return comment;
 }
コード例 #4
0
 public abstract bool UpdateComment(CommentDetails article);
コード例 #5
0
 public abstract int InsertComment(CommentDetails article);
コード例 #6
0
 protected virtual CommentDetails GetCommentFromReader(IDataReader reader)
 {
     CommentDetails comment = new CommentDetails(
         (int)reader["CommentID"],
         (DateTime)reader["AddedDate"],
         reader["AddedBy"].ToString(),
         reader["AddedByEmail"].ToString(),
         reader["AddedbyIP"].ToString(),
         0,
         (int)reader["ProgramID"],
         reader["ProgramTitle"].ToString(),
         reader["Body"].ToString());
     return comment;
 }
コード例 #7
0
 public abstract int InsertComment(CommentDetails comment);