From 93e231928f015654d5803d2f3720377b220e003f Mon Sep 17 00:00:00 2001 From: Julien Leicher Date: Tue, 22 Dec 2020 10:47:22 +0100 Subject: [PATCH] mvc-styles (#28) --- Application/GetLinkComments/CommentDto.cs | 1 + .../GetLinkCommentsQueryHandler.cs | 2 + Apps/Website/Models/RegisterViewModel.cs | 1 + Apps/Website/Startup.cs | 2 +- Apps/Website/Views/Accounts/Login.cshtml | 21 +- Apps/Website/Views/Accounts/Register.cshtml | 30 ++- Apps/Website/Views/Links/Create.cshtml | 7 +- Apps/Website/Views/Links/Index.cshtml | 5 +- Apps/Website/Views/Links/Show.cshtml | 20 +- .../Shared/Components/Login/Default.cshtml | 4 +- .../Shared/Components/Login/LoggedIn.cshtml | 10 +- Apps/Website/Views/Shared/_CommentForm.cshtml | 21 +- Apps/Website/Views/Shared/_CommentItem.cshtml | 31 ++- Apps/Website/Views/Shared/_Layout.cshtml | 54 ++-- Apps/Website/Views/Shared/_LinkItem.cshtml | 31 ++- Apps/Website/wwwroot/css/site.css | 231 +++++++++++++----- 16 files changed, 305 insertions(+), 166 deletions(-) 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/Models/RegisterViewModel.cs b/Apps/Website/Models/RegisterViewModel.cs index ae41de5..a3fae33 100644 --- a/Apps/Website/Models/RegisterViewModel.cs +++ b/Apps/Website/Models/RegisterViewModel.cs @@ -12,6 +12,7 @@ namespace Website.Models [Required] [Compare(nameof(Password))] + [Display(Name = "Password confirmation")] public string PasswordConfirm { get; set; } } } \ No newline at end of file diff --git a/Apps/Website/Startup.cs b/Apps/Website/Startup.cs index 5aa2e61..b2ca043 100644 --- a/Apps/Website/Startup.cs +++ b/Apps/Website/Startup.cs @@ -107,7 +107,7 @@ namespace Website { endpoints.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); + pattern: "{controller=Links}/{action=Index}/{id?}"); }); } diff --git a/Apps/Website/Views/Accounts/Login.cshtml b/Apps/Website/Views/Accounts/Login.cshtml index 3644db5..f4ede90 100644 --- a/Apps/Website/Views/Accounts/Login.cshtml +++ b/Apps/Website/Views/Accounts/Login.cshtml @@ -1,13 +1,20 @@ @model LoginViewModel +@{ + ViewData["Title"] = "Login"; +} -
- - - + +
+ + + +
- - - +
+ + + +
diff --git a/Apps/Website/Views/Accounts/Register.cshtml b/Apps/Website/Views/Accounts/Register.cshtml index efc99ba..1f0a344 100644 --- a/Apps/Website/Views/Accounts/Register.cshtml +++ b/Apps/Website/Views/Accounts/Register.cshtml @@ -1,17 +1,27 @@ @model RegisterViewModel +@{ + ViewData["Title"] = "Register"; +} -
- - - + - - - +
+ + + +
- - - +
+ + + +
+ +
+ + + +
\ No newline at end of file diff --git a/Apps/Website/Views/Links/Create.cshtml b/Apps/Website/Views/Links/Create.cshtml index 2161b0d..2512895 100644 --- a/Apps/Website/Views/Links/Create.cshtml +++ b/Apps/Website/Views/Links/Create.cshtml @@ -3,15 +3,16 @@ ViewData["Title"] = "Post a new link"; } -
-
- @* @Html.LabelFor(m => m.Url) + + @* @Html.LabelFor(m => m.Url) @Html.EditorFor(m => m.Url) @Html.ValidationMessageFor(m => m.Url) *@ +
+ diff --git a/Apps/Website/Views/Links/Index.cshtml b/Apps/Website/Views/Links/Index.cshtml index ffd5c2c..c569ab4 100644 --- a/Apps/Website/Views/Links/Index.cshtml +++ b/Apps/Website/Views/Links/Index.cshtml @@ -3,10 +3,9 @@ ViewData["Title"] = "Latest Links"; } -Post a new super duber link +Share a link with the world! -

Here are the links

-
    +