本文整理汇总了C#中Post.AddComment方法的典型用法代码示例。如果您正苦于以下问题:C# Post.AddComment方法的具体用法?C# Post.AddComment怎么用?C# Post.AddComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post.AddComment方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanSaveAndDeletePostWithComments
public virtual void CanSaveAndDeletePostWithComments()
{
var post = new Post();
post.AddComment(new Comment());
_session.Save(post);
_session.Flush();
_session.Delete(post);
_session.Flush();
}
示例2: AddCommentToBlogPost
public void AddCommentToBlogPost(string body, bool userSubscribed, User user, Post post)
{
var comment = new Comment
{
Body = body,
User = user,
Post = post,
UserSubscribed = userSubscribed
};
//TODO: Need to implement publishing/pending stuff
comment.Published = DateTime.UtcNow;
post.AddComment(comment);
_repository.Save(post);
}
示例3: AddCommentToBlogPost
public void AddCommentToBlogPost(string body, bool userSubscribed, User user, Post post, string twitterUserName)
{
if (string.IsNullOrEmpty(twitterUserName))
twitterUserName = string.Empty;
var comment = new Comment
{
Body = body,
User = user,
Post = post,
UserSubscribed = userSubscribed,
TwitterUserName = twitterUserName,
};
//TODO: Need to implement publishing/pending stuff
comment.Published = DateTime.UtcNow;
post.AddComment(comment);
_repository.Save(post);
_twitterService.SendCommentPostedReply(post, twitterUserName, user.DisplayName);
}
示例4: AddComment
/// <summary>
/// Insert the pingback as a comment on the post.
/// </summary>
/// <param name="sourceUrl">
/// The source Url.
/// </param>
/// <param name="post">
/// The post to comment on.
/// </param>
/// <param name="blogName">
/// The blog Name.
/// </param>
/// <param name="title">
/// The title.
/// </param>
/// <param name="excerpt">
/// The excerpt.
/// </param>
private static void AddComment(string sourceUrl, Post post, string blogName, string title, string excerpt)
{
var comment = new Comment
{
Id = Guid.NewGuid(),
Author = blogName,
Website = new Uri(sourceUrl),
Content = title + Environment.NewLine + Environment.NewLine + excerpt,
Email = "trackback",
Parent = post,
DateCreated = DateTime.Now,
IP = HttpContext.Current.Request.UserHostAddress,
IsApproved = true
};
post.AddComment(comment);
}
示例5: AddComment
/// <summary>
/// Insert the pingback as a comment on the post.
/// </summary>
private void AddComment(string sourceUrl, Post post)
{
Comment comment = new Comment();
comment.Id = Guid.NewGuid();
comment.Author = GetDomain(sourceUrl);
comment.Website = new Uri(sourceUrl);
comment.Content = "Pingback from " + comment.Author + Environment.NewLine + Environment.NewLine + _Title;
comment.DateCreated = DateTime.Now;
comment.Email = "pingback";
comment.IP = HttpContext.Current.Request.UserHostAddress;
comment.Parent = post;
comment.IsApproved = true; //NOTE: Pingback comments are approved by default.
post.AddComment(comment);
}
示例6: setup_sample_post
private void setup_sample_post(User user)
{
var oxiteTag = new Tag {Name = "Oxite", CreatedDate = DateTime.Parse("12 NOV 2008")};
var defaultPost = new Post
{
Title = "World.Hello()",
Slug = "World_Hello",
BodyShort = "Welcome to Oxite! This is a sample application targeting developers built on <a href=\"http://asp.net/mvc\">ASP.NET MVC</a>. Make any changes you like. If you build a feature you think other developers would be interested in and would like to share your code go to the <a href=\"http://www.codeplex.com/oxite\">Oxite Code Plex project</a> to see how you can contribute.<br /><br />To get started, sign in with \"Admin\" and \"pa$$w0rd\" and click on the Admin tab.<br /><br />For more information about <a href=\"http://oxite.net\">Oxite</a> visit the default <a href=\"/About\">About</a> page.",
Body = "Welcome to Oxite! This is a sample application targeting developers built on <a href=\"http://asp.net/mvc\">ASP.NET MVC</a>. Make any changes you like. If you build a feature you think other developers would be interested in and would like to share your code go to the <a href=\"http://www.codeplex.com/oxite\">Oxite Code Plex project</a> to see how you can contribute.<br /><br />To get started, sign in with \"Admin\" and \"pa$$w0rd\" and click on the Admin tab.<br /><br />For more information about <a href=\"http://oxite.net\">Oxite</a> visit the default <a href=\"/About\">About</a> page.",
Published = DateTime.Parse("2008-12-05 09:29:03.270"),
User = user
};
defaultPost.AddTag(oxiteTag);
_repository.Save(defaultPost);
var defaultPost1 = new Post
{
Title = "World.Hello()",
Slug = "World_Hello2",
BodyShort = "Welcome to Oxite! This is a sample application targeting developers built on <a href=\"http://asp.net/mvc\">ASP.NET MVC</a>. Make any changes you like. If you build a feature you think other developers would be interested in and would like to share your code go to the <a href=\"http://www.codeplex.com/oxite\">Oxite Code Plex project</a> to see how you can contribute.<br /><br />To get started, sign in with \"Admin\" and \"pa$$w0rd\" and click on the Admin tab.<br /><br />For more information about <a href=\"http://oxite.net\">Oxite</a> visit the default <a href=\"/About\">About</a> page.",
Body = "Welcome to Oxite! This is a sample application targeting developers built on <a href=\"http://asp.net/mvc\">ASP.NET MVC</a>. Make any changes you like. If you build a feature you think other developers would be interested in and would like to share your code go to the <a href=\"http://www.codeplex.com/oxite\">Oxite Code Plex project</a> to see how you can contribute.<br /><br />To get started, sign in with \"Admin\" and \"pa$$w0rd\" and click on the Admin tab.<br /><br />For more information about <a href=\"http://oxite.net\">Oxite</a> visit the default <a href=\"/About\">About</a> page.",
Published = DateTime.Parse("2008-12-05 09:29:03.270"),
User = user
};
defaultPost1.AddTag(oxiteTag);
defaultPost1.AddTag(new Tag { Name = "AltOxite", CreatedDate = DateTime.Parse("30 DEC 2008") });
defaultPost1.AddComment(new Comment { Post = defaultPost1, User = user, Body = "test comment", Published = DateTime.Parse("31 DEC 2008") });
_repository.Save(defaultPost1);
}
示例7: AddComment
/// <summary>
/// Insert the pingback as a comment on the post.
/// </summary>
private static void AddComment(string sourceUrl, Post post, string blogName, string excerpt)
{
Comment comment = new Comment();
comment.Id = Guid.NewGuid();
comment.Author = blogName;
comment.Website = new Uri(sourceUrl);
comment.Content = "Trackback from " + comment.Author + Environment.NewLine + Environment.NewLine + excerpt;
comment.Email = "trackback";
comment.Parent = post;
comment.DateCreated = DateTime.Now;
comment.IP = HttpContext.Current.Request.UserHostAddress;
comment.IsApproved = true; //NOTE: Trackback comments are approved by default
post.AddComment(comment);
}
示例8: AddComment
/// <summary>
/// Insert the pingback as a comment on the post.
/// </summary>
/// <param name="sourceUrl">
/// The source Url.
/// </param>
/// <param name="post">
/// The post to add the comment to.
/// </param>
private void AddComment(string sourceUrl, Post post)
{
var comment = new Comment
{
Id = Guid.NewGuid(),
Author = GetDomain(sourceUrl),
Website = new Uri(sourceUrl)
};
comment.Content = string.Format("Pingback from {0}{1}{2}{3}", comment.Author, Environment.NewLine, Environment.NewLine, this.title);
comment.DateCreated = DateTime.Now;
comment.Email = "pingback";
comment.IP = HttpContext.Current.Request.UserHostAddress;
comment.Parent = post;
comment.IsApproved = true; // NOTE: Pingback comments are approved by default.
post.AddComment(comment);
}