Created
February 23, 2012 16:51
-
-
Save davecowart/1893715 to your computer and use it in GitHub Desktop.
Nested Comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model FollowMyBuild.Web.Models.ViewModels.Portable.PortableComment | |
<section class="project_comment"> | |
<span class="comment_author">@Model.AuthorName</span> | |
<span class="comment_timestamp">@Model.Timestamp.ToLongTimeString()</span> | |
<p>@Model.Body</p> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using FollowMyBuild.Web.Models.ViewModels.Portable | |
@model IEnumerable<PortableComment> | |
<div id="comments"> | |
@foreach (var comment in Model.Where(c => !c.ReplyTo.HasValue)) { | |
@Html.Partial("_RecursiveComment", new PortableRecursiveComment { Id = comment.Id, Comments = Model }) | |
} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using FollowMyBuild.Web.Models.ViewModels.Portable | |
@model PortableRecursiveComment | |
@Html.Partial("_Comment", Model.Comments.FirstOrDefault(c => c.Id == Model.Id)) | |
<div class="comment_indent" style="margin-left: 15px;"> | |
@foreach (var childComment in Model.Comments.Where(c => c.ReplyTo == Model.Id)) { | |
@Html.Partial("_RecursiveComment", new PortableRecursiveComment { Id = childComment.Id, Comments = Model.Comments }) | |
} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace FollowMyBuild.Web.Models.ViewModels.Portable { | |
public class PortableRecursiveComment { | |
public PortableRecursiveComment() { | |
Comments = new List<PortableComment>(); | |
} | |
public int Id { get; set; } | |
public IEnumerable<PortableComment> Comments { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment