Users { get; }
}
}
\ No newline at end of file
diff --git a/Application/IUser.cs b/Application/IUser.cs
new file mode 100644
index 0000000..17f32e6
--- /dev/null
+++ b/Application/IUser.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Application
+{
+ public interface IUser
+ {
+ Guid Id { get; }
+ string UserName { get; }
+ }
+}
\ No newline at end of file
diff --git a/Application/LinkDTO.cs b/Application/LinkDTO.cs
index daeea23..5f16026 100644
--- a/Application/LinkDTO.cs
+++ b/Application/LinkDTO.cs
@@ -10,5 +10,6 @@ namespace Application
public int UpvotesCount { get; set; }
public int DownvotesCount { get; set; }
public int CommentsCount { get; set; }
+ public string CreatedByUsername { get; set; }
}
}
\ No newline at end of file
diff --git a/Application/LinkService.cs b/Application/LinkService.cs
index abda42b..5a226f9 100644
--- a/Application/LinkService.cs
+++ b/Application/LinkService.cs
@@ -52,6 +52,7 @@ namespace Application
{
return (from link in _data.Links
// join comment in _data.Comments on link.Id equals comment.LinkId into comments
+ join user in _data.Users on link.CreatedBy equals user.Id
orderby link.CreatedAt descending
select new LinkDTO
{
@@ -61,6 +62,7 @@ namespace Application
UpvotesCount = 2,
DownvotesCount = 4,
CommentsCount = _data.Comments.Count(comment => comment.LinkId == link.Id), //comments.Count(),
+ CreatedByUsername = user.UserName,
});
// return _data.Links
diff --git a/Apps/Website/Views/Links/Show.cshtml b/Apps/Website/Views/Links/Show.cshtml
index d1ee4a8..a1a5b23 100644
--- a/Apps/Website/Views/Links/Show.cshtml
+++ b/Apps/Website/Views/Links/Show.cshtml
@@ -19,7 +19,7 @@ else
@foreach (var comment in Model.Comments)
{
- - @comment.Content
+ - @comment.Content - @comment.CreatedByUsername
}
}
\ No newline at end of file
diff --git a/Apps/Website/Views/Shared/_LinkItem.cshtml b/Apps/Website/Views/Shared/_LinkItem.cshtml
index c4b25b2..85beb5f 100644
--- a/Apps/Website/Views/Shared/_LinkItem.cshtml
+++ b/Apps/Website/Views/Shared/_LinkItem.cshtml
@@ -4,7 +4,7 @@
@Model.Url
Show
- - Published at @Model.CreatedAt.ToLongDateString()
+ - Published at @Model.CreatedAt.ToLongDateString() by @Model.CreatedByUsername
- 🗨 @Model.CommentsCount
- 👍 @Model.UpvotesCount / 👎 @Model.DownvotesCount
diff --git a/Infrastructure/HNDbContext.cs b/Infrastructure/HNDbContext.cs
index 1e80adb..826c5d3 100644
--- a/Infrastructure/HNDbContext.cs
+++ b/Infrastructure/HNDbContext.cs
@@ -17,6 +17,8 @@ namespace Infrastructure
IQueryable IData.Comments => Comments;
+ IQueryable IData.Users => Users;
+
public HNDbContext() : base()
{
diff --git a/Infrastructure/Identity/User.cs b/Infrastructure/Identity/User.cs
index d696a93..25effe9 100644
--- a/Infrastructure/Identity/User.cs
+++ b/Infrastructure/Identity/User.cs
@@ -1,9 +1,10 @@
using System;
+using Application;
using Microsoft.AspNetCore.Identity;
namespace Infrastructure.Identity
{
- public class User : IdentityUser
+ public class User : IdentityUser, IUser
{
// On peut ajouter des propriétés ici au besoin
}
diff --git a/Infrastructure/Repositories/Memory/Data.cs b/Infrastructure/Repositories/Memory/Data.cs
index 3050981..3f52e1e 100644
--- a/Infrastructure/Repositories/Memory/Data.cs
+++ b/Infrastructure/Repositories/Memory/Data.cs
@@ -13,6 +13,8 @@ namespace Infrastructure.Repositories.Memory
public IQueryable Comments => _commentRepository.Comments.AsQueryable();
+ public IQueryable Users => throw new System.NotImplementedException();
+
public Data(LinkRepository linkRepository, CommentRepository commentRepository)
{
_linkRepository = linkRepository;