diff --git a/Application/GetLinkComments/CommentDto.cs b/Application/GetLinkComments/CommentDto.cs index 0ff565d..0830c13 100644 --- a/Application/GetLinkComments/CommentDto.cs +++ b/Application/GetLinkComments/CommentDto.cs @@ -7,6 +7,7 @@ namespace HN.Application public Guid Id { get; set; } public string Content { get; set; } public DateTime CreatedAt { get; set; } + public string CreatedByName { get; set; } public int UpVotes { get; set; } public int DownVotes { get; set; } diff --git a/Application/GetLinkComments/GetLinkCommentsQueryHandler.cs b/Application/GetLinkComments/GetLinkCommentsQueryHandler.cs index 08e3a0d..28264b8 100644 --- a/Application/GetLinkComments/GetLinkCommentsQueryHandler.cs +++ b/Application/GetLinkComments/GetLinkCommentsQueryHandler.cs @@ -18,11 +18,13 @@ namespace HN.Application public Task Handle(GetLinkCommentsQuery request, CancellationToken cancellationToken) { var comments = from comment in _context.Comments + join user in _context.Users on comment.CreatedBy equals user.Id where comment.LinkId == request.LinkId select new CommentDto { Id = comment.Id, CreatedAt = comment.CreatedAt, + CreatedByName = user.UserName, Content = comment.Content, UpVotes = comment.Votes.Count(c => c.Type == VoteType.Up), DownVotes = comment.Votes.Count(c => c.Type == VoteType.Down) diff --git a/Apps/Website/Views/Links/Show.cshtml b/Apps/Website/Views/Links/Show.cshtml index 8e1bfd6..50e8e04 100644 --- a/Apps/Website/Views/Links/Show.cshtml +++ b/Apps/Website/Views/Links/Show.cshtml @@ -1,14 +1,22 @@ @model ShowLinkViewModel +@{ + ViewData["Title"] = "Viewing"; +} -@if(Model.Comments.Length == 0) { -

No comments yet

-} else { -