コード例 #1
0
        /// <summary>
        /// Inserts Comment into the Comments Table
        /// </summary>
        /// <param name="comment">A new populated comment.</param>
        /// <returns>Insert Count</returns>
        public int Insert(Comment comment)
        {
            DbParameter outParameter = database.MakeParameter("@Identity", 0, ParameterDirection.Output);

            List<DbParameter> parameters = new List<DbParameter>
            {
                    database.MakeParameter("@Name",comment.Name),
                    database.MakeParameter("@Email",comment.Email),
                    database.MakeParameter("@SiteUrl",comment.SiteUrl),
                    database.MakeParameter("@Ip",comment.Ip),
                    database.MakeParameter("@UserAgent",comment.UserAgent),
                    database.MakeParameter("@CommentStatus",comment.CommentStatus.ToString()),
                    database.MakeParameter("@Text",comment.Text),
                    database.MakeParameter("@CommentDate",comment.CommentDate),
                    database.MakeParameter("@UserId",comment.UserId),
                    database.MakeParameter("@ParentId",comment.ParentId),
                    database.MakeParameter("@MediaId",comment.MediaId),
                    outParameter
            };

            database.NonQuery("Comment_Insert", parameters);
            return Convert.ToInt32(outParameter.Value);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaComments"/> class.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <param name="comment">The comment.</param>
 public MediaComments(Media media, Comment comment)
 {
     Media = media;
     Comment = comment;
 }
コード例 #3
0
        /// <summary>
        /// Renders the comment status.
        /// </summary>
        /// <param name="comment">The comment.</param>
        /// <returns></returns>
        public string RenderCommentStatus(Comment comment)
        {
            const string statusFormat = "<span class=\"{0}\">{1}</span>";

            string status = string.Format(statusFormat, "green", comment.CommentStatus);
            status = (comment.CommentStatus == CommentStatus.Pending ? string.Format(statusFormat, "orange", comment.CommentStatus) : status);
            status = (comment.CommentStatus == CommentStatus.Spam ? string.Format(statusFormat, "red", comment.CommentStatus) : status);

            return status;
        }
コード例 #4
0
 /// <summary>
 /// Renders the author details.
 /// </summary>
 /// <param name="comment">The comment.</param>
 /// <returns></returns>
 public string RenderAuthorDetails(Comment comment)
 {
     return string.Format(" {0}{1}{2}{3}", RenderCommentStatus(comment),
                          (string.IsNullOrEmpty(comment.Name) ? string.Empty : (string.IsNullOrEmpty(comment.SiteUrl) ? "<br />" +comment.Name : string.Format("<br /><a href=\"{0}\" title=\"Visit {1}\" >{1}</a>", comment.SiteUrl, comment.Name))),
                          (string.IsNullOrEmpty(comment.Email) ? string.Empty : string.Format("<br /><a href=\"mailto:{0}\" title=\"Email {1}\" >{2}</a>", comment.Email, comment.Name, comment.Email)),
                          (string.IsNullOrEmpty(comment.Ip) ? string.Empty : "<br />" + comment.Ip));
 }
コード例 #5
0
 //
 /// <summary>
 /// Delete a Comment by the primary key
 /// </summary>
 /// <param name="comment"></param>
 public int Delete(Comment comment)
 {
     return database.NonQuery("Comment_Delete", new{comment.CommentId});
 }
コード例 #6
0
 /// <summary>
 /// Updates the Comment table by the primary key, if the Comment is dirty then an update will occur
 /// </summary>
 /// <param name="comment">a populated comment</param>
 /// <returns>update count</returns>
 public int Update(Comment comment)
 {
     int updateCount = database.NonQuery("Comment_Update", comment);
     return updateCount;
 }
コード例 #7
0
 /// <summary>
 /// Saves the specified comment.
 /// </summary>
 /// <param name="comment">The comment.</param>
 public void Save(Comment comment)
 {
     if (comment.CommentId > 0)
     {
         Update(comment);
     }
     else
     {
         Insert(comment);
     }
 }