Fixing position for new comments

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-11-04 11:57:48 -08:00
parent 171a163a8a
commit 133b9d65c3

View File

@@ -40,7 +40,7 @@ namespace Orchard.Comments.Controllers {
var commentPart = comment.As<CommentPart>();
// ensure the comments are not closed on the container, as the html could have been tampered manually
var container = Services.ContentManager.Get(commentPart.CommentedOnContainer);
var container = Services.ContentManager.Get(commentPart.CommentedOn);
CommentsPart commentsPart = null;
if(container != null) {
commentsPart = container.As<CommentsPart>();
@@ -63,16 +63,16 @@ namespace Orchard.Comments.Controllers {
// what is the next position after the anwered comment
if(repliedPart != null) {
// the next comment is the one right after the RepliedOn one, at the same level
var nextComment = _commentService.GetCommentsForCommentedContent(commentPart.CommentedOnContainer)
var nextComment = _commentService.GetCommentsForCommentedContent(commentPart.CommentedOn)
.Where(x => x.RepliedOn == repliedPart.RepliedOn && x.CommentDateUtc > repliedPart.CommentDateUtc)
.OrderBy(x => x.CommentDateUtc)
.OrderBy(x => x.Position)
.Slice(0, 1)
.FirstOrDefault();
// the previous comment is the last one under the RepliedOn
var previousComment = _commentService.GetCommentsForCommentedContent(commentPart.CommentedOnContainer)
var previousComment = _commentService.GetCommentsForCommentedContent(commentPart.CommentedOn)
.Where(x => x.RepliedOn == commentPart.RepliedOn)
.OrderByDescending(x => x.CommentDateUtc)
.OrderByDescending(x => x.Position)
.Slice(0, 1)
.FirstOrDefault();
@@ -92,7 +92,9 @@ namespace Orchard.Comments.Controllers {
}
else {
// new comment, last in position
commentPart.RepliedOn = null;
commentPart.Position = comment.Id;
}
if (commentPart.Status == CommentStatus.Pending) {