From db6d0aab31c592a484df2c7216330fc5457f30bb Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 30 Nov 2021 16:57:49 -0500 Subject: [PATCH] Use ASP.NET Partials for photo rendering --- .../Pages/Partials/PhotoPartial.cshtml | 22 +++++++++++++++++++ ProjectLighthouse/Pages/PhotosPage.cshtml | 20 +---------------- ProjectLighthouse/Pages/UserPage.cshtml | 15 +++---------- 3 files changed, 26 insertions(+), 31 deletions(-) create mode 100644 ProjectLighthouse/Pages/Partials/PhotoPartial.cshtml diff --git a/ProjectLighthouse/Pages/Partials/PhotoPartial.cshtml b/ProjectLighthouse/Pages/Partials/PhotoPartial.cshtml new file mode 100644 index 00000000..33a8fbc1 --- /dev/null +++ b/ProjectLighthouse/Pages/Partials/PhotoPartial.cshtml @@ -0,0 +1,22 @@ +@using LBPUnion.ProjectLighthouse.Types +@model LBPUnion.ProjectLighthouse.Types.Photo + + +
+ +

+ + Taken by + + @Model.Creator?.Username + + +

+ +

+ Photo contains @Model.Subjects.Count @(Model.Subjects.Count == 1 ? "person" : "people"): +

+@foreach (PhotoSubject subject in Model.Subjects) +{ + @subject.User.Username +} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/PhotosPage.cshtml b/ProjectLighthouse/Pages/PhotosPage.cshtml index 844165ca..e579cbc3 100644 --- a/ProjectLighthouse/Pages/PhotosPage.cshtml +++ b/ProjectLighthouse/Pages/PhotosPage.cshtml @@ -12,25 +12,7 @@ @foreach (Photo photo in Model.Photos) {
- -
- -

- - Taken by - - @photo.Creator.Username - - -

- -

- Photo contains @photo.Subjects.Count @(photo.Subjects.Count == 1 ? "person" : "people"): -

- @foreach (PhotoSubject subject in photo.Subjects) - { - @subject.User.Username - } + @await Html.PartialAsync("Partials/PhotoPartial", photo)
} diff --git a/ProjectLighthouse/Pages/UserPage.cshtml b/ProjectLighthouse/Pages/UserPage.cshtml index d23cc01c..68317395 100644 --- a/ProjectLighthouse/Pages/UserPage.cshtml +++ b/ProjectLighthouse/Pages/UserPage.cshtml @@ -6,7 +6,7 @@ @{ Layout = "Layouts/BaseLayout"; - Model.Title = "Model.ProfileUser!.Username's user page"; + Model.Title = Model.ProfileUser!.Username + "'s user page"; Model.ShowTitleInPage = false; } @@ -14,7 +14,7 @@

@Model.Title

- @Model.ProfileUser.Status + @Model.ProfileUser!.Status

@Model.ProfileUser.Hearts @@ -74,16 +74,7 @@ @foreach (Photo photo in Model.Photos) {
- -
- -

- Photo contains @photo.Subjects.Count @(photo.Subjects.Count == 1 ? "person" : "people"): -

- @foreach (PhotoSubject subject in photo.Subjects) - { - @subject.User.Username - } + @await Html.PartialAsync("Partials/PhotoPartial", photo);
}