Fixing comments notifications

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-11-04 21:43:48 -08:00
parent aedadd1d94
commit 37f0fbd41e
2 changed files with 6 additions and 5 deletions

View File

@@ -32,9 +32,10 @@ namespace Orchard.Comments.Controllers {
var comment = Services.ContentManager.New("Comment");
Services.ContentManager.Create(comment);
var editorShape = Services.ContentManager.UpdateEditor(comment, this);
Services.ContentManager.Create(comment);
if (ModelState.IsValid) {
if (comment.Has<CommentPart>()) {
var commentPart = comment.As<CommentPart>();

View File

@@ -30,16 +30,16 @@ namespace Orchard.Comments.Tokens {
public void Evaluate(dynamic context) {
context.For<IContent>("Content")
.Token("CommentedOn", (Func<IContent, object>)(content => content.As<CommentPart>().Record.CommentedOn))
.Chain("CommentedOn", "Content", (Func<IContent, object>)(content => _contentManager.Get(content.As<CommentPart>().Record.CommentedOn)))
.Token("CommentMessage", (Func<IContent, object>)(content => content.As<CommentPart>().Record.CommentText))
.Token("CommentedOn", (Func<IContent, object>)(content => content.As<CommentPart>().CommentedOn))
.Chain("CommentedOn", "Content", (Func<IContent, object>)(content => _contentManager.Get(content.As<CommentPart>().CommentedOn)))
.Token("CommentMessage", (Func<IContent, object>)(content => content.As<CommentPart>().CommentText))
.Token("CommentAuthor", (Func<IContent, object>)CommentAuthor)
;
}
private static string CommentAuthor(IContent comment) {
var commentPart = comment.As<CommentPart>();
return String.IsNullOrWhiteSpace(commentPart.Record.UserName) ? commentPart.Record.Author : commentPart.Record.UserName;
return String.IsNullOrWhiteSpace(commentPart.UserName) ? commentPart.Author : commentPart.UserName;
}
}
}