From 76e8e8daa6688ad3b6318c193a505686a46f8e57 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 4 Jan 2026 20:27:17 +0100 Subject: [PATCH] feat: added Currently Watching to PrivateList --- CouchLog/Components/Pages/PrivateList.razor | 286 ++++++++++---------- 1 file changed, 145 insertions(+), 141 deletions(-) diff --git a/CouchLog/Components/Pages/PrivateList.razor b/CouchLog/Components/Pages/PrivateList.razor index bd5bc47..545671e 100644 --- a/CouchLog/Components/Pages/PrivateList.razor +++ b/CouchLog/Components/Pages/PrivateList.razor @@ -16,139 +16,41 @@ Private List
-
-

Private List

-
- -
- @foreach (var Entity in PrivateEntities) - { -
- -
-
- - -
- @if (!string.IsNullOrEmpty(Entity.GlobalEntity?.PicturePath)) - { - @Entity.GlobalEntity.Title - } - else - { -
- Kein Bild -
- } -
- - -
-
- - -
-
-
- @Entity.GlobalEntity?.Title -
- - @Entity.CreationTime.ToShortDateString() - -
- - -
- - - - @if (Entity.GlobalEntity?.MediaType.Name == "Series" || Entity.GlobalEntity?.MediaType.Name == "Anime") - { - - - - } - - - - -
- -
-
-
-
-
- - - + + @if (ActiveWatchingEntities.Any()) + { +
+

Aktiv am Schauen

+
+ @foreach (var entity in ActiveWatchingEntities) + { + @RenderEntityCard(entity) + }
- } -
+
+ } + + + @if (LibraryEntities.Any()) + { +
+

Bibliothek

+
+ @foreach (var entity in LibraryEntities) + { + @RenderEntityCard(entity) + } +
+
+ } + + @if (!PrivateEntities.Any()) + { +
+

Keine Einträge vorhanden.

+
+ }
@code @@ -157,6 +59,9 @@ private List userWatchStatuses = new List(); ApplicationUser? AppUser = new(); + private List ActiveWatchingEntities => PrivateEntities.Where(x => x.UserWatchStatus?.Name == "Watching").ToList(); + private List LibraryEntities => PrivateEntities.Where(x => x.UserWatchStatus?.Name != "Watching").ToList(); + protected override async Task OnInitializedAsync() { var AuthState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); @@ -176,30 +81,130 @@ } } + private RenderFragment RenderEntityCard(PrivateEntity Entity) => __builder => + { +
+
+
+ +
+ @if (!string.IsNullOrEmpty(Entity.GlobalEntity?.PicturePath)) + { + @Entity.GlobalEntity.Title + } + else + { +
+ Kein Bild +
+ } +
+ + +
+
+ + +
+
+
+ @Entity.GlobalEntity?.Title +
+ + @Entity.CreationTime.ToShortDateString() + +
+ + +
+ + + + + @if (Entity.GlobalEntity?.MediaType.Name == "Series" || Entity.GlobalEntity?.MediaType.Name == "Anime") + { + + + + } + + +
+ +
+
+
+
+
+ + + +
+ }; + private async Task UpdateWatchStatus(PrivateEntity entity, object? newValue) { - // Wir holen uns die gewählte ID aus dem Dropdown if (int.TryParse(newValue?.ToString(), out int newId)) { - // 1. ID im Objekt aktualisieren entity.UserWatchStatusId = newId; - - // 2. Navigation Property aktualisieren (damit die UI nicht flackert) - // Wir suchen das passende Objekt aus der geladenen Liste entity.UserWatchStatus = userWatchStatuses.FirstOrDefault(s => s.Id == newId); - - // 3. Ab in die Datenbank await CouchLogDB.SaveChangesAsync(); } } private async Task UpdateSeason(PrivateEntity entity, object? newSeasonValue) { - if(int.TryParse(newSeasonValue?.ToString(), out int newSeason)) + if (int.TryParse(newSeasonValue?.ToString(), out int newSeason)) { entity.Season = newSeason; entity.Episode = 1; - await CouchLogDB.SaveChangesAsync(); } } @@ -209,7 +214,6 @@ if (int.TryParse(newEpisodeValue?.ToString(), out int newEpisode)) { entity.Episode = newEpisode; - await CouchLogDB.SaveChangesAsync(); } }