/// <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; } }
/// <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); } }
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; }
public abstract bool UpdateComment(CommentDetails article);
public abstract int InsertComment(CommentDetails article);
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; }
public abstract int InsertComment(CommentDetails comment);