From ab773f8b715f2f52b1682d25b47a371bb53a9376 Mon Sep 17 00:00:00 2001 From: Maxime Adler Date: Tue, 13 May 2025 14:03:42 +0200 Subject: [PATCH] Fix wrong comportment --- .../GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs | 6 +++++- .../Pages/Games/Components/GameRow.razor | 2 +- .../Client/GameIdeas.BlazorApp/Pages/Games/Games.razor | 2 +- .../Client/GameIdeas.BlazorApp/Pages/Games/Games.razor.cs | 5 +++++ .../Shared/Components/GameBaseComponent.cs | 2 +- .../GameIdeas.WebAPI/Services/Games/GameWriteService.cs | 5 +++++ 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs index b5c9615..938d9f3 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameBase.cs @@ -1,4 +1,5 @@ -using GameIdeas.BlazorApp.Shared.Components.Select.Models; +using GameIdeas.BlazorApp.Shared.Components.Select; +using GameIdeas.BlazorApp.Shared.Components.Select.Models; using GameIdeas.Resources; using GameIdeas.Shared.Dto; using Microsoft.AspNetCore.Components; @@ -13,6 +14,7 @@ public class GameBase : ComponentBase [Inject] public NavigationManager NavigationManager { get; set; } = default!; protected SelectParams SelectParams = default!; + protected Select? SelectOption; protected override void OnInitialized() { @@ -40,6 +42,8 @@ public class GameBase : ComponentBase default: break; } + + SelectOption?.Close(); } private string GetDetailOptionsLabel(DetailOptions options) diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor index dae3abf..059bc90 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor @@ -35,7 +35,7 @@ - diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor index 8dcc928..73b7dc7 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor @@ -42,7 +42,7 @@ - + diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor.cs index 8bf0a38..dc72481 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor.cs @@ -111,4 +111,9 @@ public partial class Games : GameBaseComponent GameIdToUpdate = null; } + private async Task HandleOnSubmitGame() + { + await HandleFetchDatas(false); + await HandleFetchCategories(); + } } \ No newline at end of file diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/GameBaseComponent.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/GameBaseComponent.cs index 8839cdd..54fee3a 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/GameBaseComponent.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/GameBaseComponent.cs @@ -19,7 +19,7 @@ public class GameBaseComponent : ComponentBase await base.OnInitializedAsync(); } - private async Task HandleFetchCategories() + protected async Task HandleFetchCategories() { try { diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Games/GameWriteService.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Games/GameWriteService.cs index 4e87bc5..af144ee 100644 --- a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Games/GameWriteService.cs +++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Games/GameWriteService.cs @@ -89,6 +89,8 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW context.Platforms.AttachRange(gps.Select(gp => gp.Platform)); await context.GamePlatforms.AddRangeAsync(gps); + await context.SaveChangesAsync(); + context.Platforms.RemoveRange( context.Platforms.Include(p => p.GamePlatforms) .Where(p => p.GamePlatforms.Count == 0)); @@ -114,6 +116,8 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW context.Properties.AttachRange(gps.Select(gp => gp.Property)); await context.GameProperties.AddRangeAsync(gps); + await context.SaveChangesAsync(); + context.Properties.RemoveRange( context.Properties.Include(p => p.GameProperties) .Where(p => p.GameProperties.Count == 0)); @@ -139,6 +143,7 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW context.Tags.AttachRange(gts.Select(gt => gt.Tag)); await context.GameTags.AddRangeAsync(gts); + await context.SaveChangesAsync(); context.Tags.RemoveRange( context.Tags.Include(t => t.GameTags)