diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Helpers/GameHelper.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Helpers/GameHelper.cs
index f33ea26..27df03e 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Helpers/GameHelper.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Helpers/GameHelper.cs
@@ -13,7 +13,7 @@ public static class GameHelper
throw new ArgumentNullException(nameof(authState), "Authentication state missing");
}
- var userId = authState.User.FindFirstValue(ClaimTypes.Sid)
+ var userId = authState.User.FindFirstValue(ClaimTypes.Sid)
?? throw new ArgumentNullException(nameof(authState), "user state missing");
game.CreationUserId = userId;
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs
index 24ec5e9..e7d107f 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs
@@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.JSInterop;
-using System.Security.Claims;
namespace GameIdeas.BlazorApp.Pages.Games.Components;
@@ -21,7 +20,7 @@ public partial class GameCreationForm
[Parameter] public CategoriesDto? Categories { get; set; }
[Parameter] public EventCallback OnSubmit { get; set; }
- private GameDetailDto GameDto = new();
+ private readonly GameDetailDto GameDto = new();
private EditContext? EditContext;
private readonly SelectTheme Theme = SelectTheme.Creation;
private readonly SliderParams SliderParams = new() { Gap = 1, Min = 1, Max = 5 };
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 180382d..5ecb8ac 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor
@@ -4,7 +4,7 @@
@inherits GameBase
-

+
@GameDto.Title
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor.css
index 14d3ae6..b086db3 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor.css
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameRow.razor.css
@@ -80,9 +80,20 @@
fill: var(--white);
}
+@media screen and (max-width: 700px) {
+ .release-date {
+ display: none;
+ grid-column: span;
+ }
+
+ .row {
+ grid-template-columns: auto 3fr 3fr 30px 30px !important;
+ }
+}
+
@media screen and (max-width: 1000px) {
.row {
- grid-template-columns: 48px 3fr 2fr 3fr 30px 30px;
+ grid-template-columns: auto 3fr 2fr 3fr 30px 30px;
}
.tags, .storage {
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 d165867..3a334de 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Games.razor.cs
@@ -26,7 +26,7 @@ public partial class Games
GameFilter.SortType = Filter.GameFilter.SortTypes
.First(st => st.SortType == SortType.Ascending);
- GameFilter.SortProperty= Filter.GameFilter.GameProperties
+ GameFilter.SortProperty = Filter.GameFilter.GameProperties
.First(gp => gp.PropertyName == nameof(GameIdeas.Shared.Model.Game.Title));
await HandleFetchDatas();
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Gateways/GameGateway.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Gateways/GameGateway.cs
index 1ed7cfe..12f57d2 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Gateways/GameGateway.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Gateways/GameGateway.cs
@@ -26,7 +26,7 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
try
{
var result = await httpClientService.FetchDataAsync
(Endpoints.Category.AllCategories);
-
+
return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchCategories);
}
catch (Exception)
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/UserMenu/Components/Login.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/UserMenu/Components/Login.razor.cs
index 311a4ba..4fcb3f7 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/UserMenu/Components/Login.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/UserMenu/Components/Login.razor.cs
@@ -10,9 +10,9 @@ public partial class Login
[Parameter] public IAuthGateway AuthGateway { get; set; } = default!;
private EditContext? EditContext;
- private UserDto UserDto = new();
+ private readonly UserDto UserDto = new();
private bool IsLoading = false;
- private LoginValidator Validator = new();
+ private readonly LoginValidator Validator = new();
protected override void OnInitialized()
{
EditContext = new EditContext(UserDto);
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Components/UserRow.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Components/UserRow.razor.cs
index a1e0f28..f20ff7c 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Components/UserRow.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Components/UserRow.razor.cs
@@ -1,5 +1,4 @@
using FluentValidation;
-using GameIdeas.BlazorApp.Shared.Components.Select;
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components;
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Gateways/UserGateway.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Gateways/UserGateway.cs
index 2f89712..cc17d8a 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Gateways/UserGateway.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Gateways/UserGateway.cs
@@ -37,36 +37,36 @@ public class UserGateway(IHttpClientService httpClient) : IUserGateway
public async Task> GetRoles()
{
- try
- {
- return await httpClient.FetchDataAsync>(Endpoints.User.Roles)
- ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchRoles);
- }
- catch (Exception)
- {
- throw new RoleNotFoundException(ResourcesKey.ErrorFetchRoles);
+ try
+ {
+ return await httpClient.FetchDataAsync>(Endpoints.User.Roles)
+ ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchRoles);
+ }
+ catch (Exception)
+ {
+ throw new RoleNotFoundException(ResourcesKey.ErrorFetchRoles);
}
}
public async Task GetUsers(UserFilterParams filterParams, int currentPage)
{
- try
- {
- UserFilterDto filter = new()
- {
- CurrentPage = currentPage,
- Name = filterParams.Name,
- RoleIds = filterParams.Roles?.Select(r => r.Id)
- };
+ try
+ {
+ UserFilterDto filter = new()
+ {
+ CurrentPage = currentPage,
+ Name = filterParams.Name,
+ RoleIds = filterParams.Roles?.Select(r => r.Id)
+ };
- var url = Endpoints.User.Fetch(filter);
- return await httpClient.FetchDataAsync(url)
- ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchUsers);
- }
- catch (Exception)
- {
- throw new UserNotFoundException(ResourcesKey.ErrorFetchUsers);
- }
+ var url = Endpoints.User.Fetch(filter);
+ return await httpClient.FetchDataAsync(url)
+ ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchUsers);
+ }
+ catch (Exception)
+ {
+ throw new UserNotFoundException(ResourcesKey.ErrorFetchUsers);
+ }
}
public async Task UpdateUser(UserDto user)
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.cs
index bd55aba..7bd0a6b 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.cs
@@ -17,10 +17,10 @@ public partial class Users
private Popup? Popup;
private bool IsLoading = false;
- private UserFilterParams FilterParams = new();
+ private readonly UserFilterParams FilterParams = new();
private UserListDto UserList = new();
private IEnumerable Roles = [];
- private int CurrentPage = 1;
+ private readonly int CurrentPage = 1;
private UserDto UserAdd = new();
private UserDto? UserDelete;
private string? currentUserId;
@@ -34,7 +34,7 @@ public partial class Users
NavigationManager.NavigateTo("/Unauthorized");
return;
}
-
+
await FetchData();
await base.OnInitializedAsync();
@@ -57,7 +57,7 @@ public partial class Users
}
finally
{
- IsLoading = false;
+ IsLoading = false;
}
}
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Program.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Program.cs
index adb1b82..437dcf6 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Program.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Program.cs
@@ -1,4 +1,3 @@
-using System.Net.Http.Json;
using Blazored.LocalStorage;
using GameIdeas.BlazorApp;
using GameIdeas.BlazorApp.Pages.Games.Gateways;
@@ -10,6 +9,7 @@ using GameIdeas.Shared.Constants;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
+using System.Net.Http.Json;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var services = builder.Services;
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Services/HttpClientService.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Services/HttpClientService.cs
index cf82e39..a75fc5b 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Services/HttpClientService.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Services/HttpClientService.cs
@@ -1,23 +1,23 @@
-using GameIdeas.Resources;
-using System.Net.Http.Headers;
-using System.Text.Json.Serialization;
-using System.Text.Json;
-using System.Text;
-using Blazored.LocalStorage;
+using Blazored.LocalStorage;
+using GameIdeas.Resources;
using GameIdeas.Shared.Constants;
using Microsoft.AspNetCore.Components.Authorization;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Text.Json.Serialization;
namespace GameIdeas.BlazorApp.Services;
public class HttpClientService(
- IHttpClientFactory httpClientFactory,
+ IHttpClientFactory httpClientFactory,
ILoggerFactory loggerFactory,
ILocalStorageService localStorage,
AuthenticationStateProvider stateProvider) : IHttpClientService
{
private readonly HttpClient httpClient = httpClientFactory.CreateClient("GameIdeas.WebAPI");
private readonly ILogger logger = loggerFactory.CreateLogger();
-
+
private readonly JsonSerializerOptions _optionsCamelCase = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
@@ -145,8 +145,8 @@ public class HttpClientService(
{
var expired = await localStorage.GetItemAsStringAsync(GlobalConstants.LS_EXPIRED_STORAGE_KEY);
- if (expired == null
- || (DateTime.TryParse(expired, out DateTime expiration)
+ if (expired == null
+ || (DateTime.TryParse(expired, out DateTime expiration)
&& expiration < DateTime.UtcNow))
{
await ((JwtAuthenticationStateProvider)stateProvider).NotifyUserLogoutAsync();
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Services/JwtAuthenticationStateProvider.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Services/JwtAuthenticationStateProvider.cs
index 20eadc9..7d971e0 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Services/JwtAuthenticationStateProvider.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Services/JwtAuthenticationStateProvider.cs
@@ -1,9 +1,9 @@
using Blazored.LocalStorage;
-using Microsoft.AspNetCore.Components.Authorization;
-using System.Security.Claims;
-using System.IdentityModel.Tokens.Jwt;
using GameIdeas.Shared.Constants;
using GameIdeas.Shared.Dto;
+using Microsoft.AspNetCore.Components.Authorization;
+using System.IdentityModel.Tokens.Jwt;
+using System.Security.Claims;
namespace GameIdeas.BlazorApp.Services;
@@ -13,7 +13,7 @@ public class JwtAuthenticationStateProvider(ILocalStorageService localStorage) :
{
var savedToken = await localStorage.GetItemAsStringAsync(GlobalConstants.LS_AUTH_STORAGE_KEY);
- if (!string.IsNullOrWhiteSpace(savedToken))
+ if (!string.IsNullOrWhiteSpace(savedToken))
{
try
{
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor
index 97a356b..d7e725b 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/BackdropFilter/BackdropFilter.razor
@@ -35,7 +35,7 @@
}
else
{
- await Js.InvokeVoidAsync("setBodyOverflow", "auto");
+ await Js.InvokeVoidAsync("setBodyOverflow", "visible");
}
}
catch (Exception)
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/ButtonAdd/ButtonAdd.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/ButtonAdd/ButtonAdd.razor.cs
index a20fa75..9d2609b 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/ButtonAdd/ButtonAdd.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/ButtonAdd/ButtonAdd.razor.cs
@@ -1,5 +1,5 @@
-using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using GameIdeas.BlazorApp.Shared.Components.Select;
+using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using GameIdeas.BlazorApp.Shared.Models;
using GameIdeas.Resources;
using Microsoft.AspNetCore.Components;
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Header/HeaderGameIdeas.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Header/HeaderGameIdeas.razor.cs
index 1939cb3..9b777bd 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Header/HeaderGameIdeas.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Header/HeaderGameIdeas.razor.cs
@@ -1,7 +1,3 @@
-using GameIdeas.BlazorApp.Shared.Components.Select;
-using GameIdeas.BlazorApp.Shared.Components.Select.Models;
-using GameIdeas.BlazorApp.Shared.Models;
-using GameIdeas.Resources;
using Microsoft.AspNetCore.Components;
namespace GameIdeas.BlazorApp.Shared.Components.Header;
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/ReadMore/ReadMore.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/ReadMore/ReadMore.razor.cs
index 8fb9488..e36e9fe 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/ReadMore/ReadMore.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/ReadMore/ReadMore.razor.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components;
-using Microsoft.JSInterop;
namespace GameIdeas.BlazorApp.Shared.Components.ReadMore;
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs
index dc6f86f..9f2680c 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs
@@ -1,9 +1,6 @@
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
-using GameIdeas.Resources;
-using GameIdeas.Shared.Constants;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
-using System.Text.RegularExpressions;
namespace GameIdeas.BlazorApp.Shared.Components.Select;
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor.cs
index 44072ce..65d6e57 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor.cs
@@ -1,6 +1,6 @@
using GameIdeas.BlazorApp.Shared.Components.Search;
-using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using GameIdeas.BlazorApp.Shared.Components.Select;
+using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using Microsoft.AspNetCore.Components;
namespace GameIdeas.BlazorApp.Shared.Components.SelectSearch;
@@ -34,15 +34,15 @@ public partial class SelectSearch
}
private async Task HandleValuesChanged(IEnumerable values)
{
- Values = values.ToList();
+ Values = [.. values];
SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel)));
- await ValuesChanged.InvokeAsync(Values.ToList());
+ await ValuesChanged.InvokeAsync([.. Values]);
}
private async Task HandleClearClicked()
{
Values = [];
- await ValuesChanged.InvokeAsync(Values.ToList());
+ await ValuesChanged.InvokeAsync([.. Values]);
}
private void HandleFocusIn()
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Slider/SliderParams.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Slider/SliderParams.cs
index 5ba67e0..71263c7 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Slider/SliderParams.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Slider/SliderParams.cs
@@ -2,7 +2,7 @@
public class SliderParams
{
- public int Min{ get; set; }
+ public int Min { get; set; }
public int Max { get; set; }
public int Gap { get; set; } = 0;
}
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SliderRange/SliderRangeParams.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SliderRange/SliderRangeParams.cs
index 7b65539..f356a8d 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SliderRange/SliderRangeParams.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SliderRange/SliderRangeParams.cs
@@ -2,7 +2,7 @@
public class SliderRangeParams
{
- public int Min{ get; set; }
+ public int Min { get; set; }
public int Max { get; set; }
public int Gap { get; set; } = 0;
}
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Constants/Icons.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Constants/Icons.cs
index f3b906f..a943bc9 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Constants/Icons.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Constants/Icons.cs
@@ -15,7 +15,7 @@ public static class Icons
public readonly static MarkupString Triangle = new(OpenBraket +
"" +
CloseBraket);
-
+
public readonly static MarkupString Close = new(OpenBraket +
"" +
CloseBraket);
diff --git a/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs b/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs
index 20cdaf6..d40c808 100644
--- a/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs
+++ b/src/GameIdeas/GameIdeas.Resources/CreateStaticResourceKey.cs
@@ -1,7 +1,7 @@
namespace GameIdeas.Resources;
-public class Translations (TranslationService translationService)
+public class Translations(TranslationService translationService)
{
public string GamesIdeas => translationService.Translate(nameof(GamesIdeas));
public string ManualAdd => translationService.Translate(nameof(ManualAdd));
diff --git a/src/GameIdeas/GameIdeas.Resources/TranslationService.cs b/src/GameIdeas/GameIdeas.Resources/TranslationService.cs
index 8fe81fd..47bd3a4 100644
--- a/src/GameIdeas/GameIdeas.Resources/TranslationService.cs
+++ b/src/GameIdeas/GameIdeas.Resources/TranslationService.cs
@@ -5,22 +5,22 @@ namespace GameIdeas.Resources;
public class TranslationService
{
- private readonly Dictionary?> _translations = new();
+ private readonly Dictionary?> _translations = [];
- public void Initialize(Dictionary translations)
- {
- foreach (var translation in translations)
- {
- var json = JsonSerializer.Deserialize>(translation.Value);
- _translations[translation.Key] = json;
- }
- }
+ public void Initialize(Dictionary translations)
+ {
+ foreach (var translation in translations)
+ {
+ var json = JsonSerializer.Deserialize>(translation.Value);
+ _translations[translation.Key] = json;
+ }
+ }
- public string Translate(string key, string? culture = "fr")
- {
- culture ??= CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
- if (_translations.TryGetValue(culture, out var value) && value?.TryGetValue(key, out var translate) == true)
- return translate;
- return key; // Fallback to key if translation is missing
- }
+ public string Translate(string key, string? culture = "fr")
+ {
+ culture ??= CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
+ if (_translations.TryGetValue(culture, out var value) && value?.TryGetValue(key, out var translate) == true)
+ return translate;
+ return key; // Fallback to key if translation is missing
+ }
}
\ No newline at end of file
diff --git a/src/GameIdeas/GameIdeas.Shared/Dto/CategoriesDto.cs b/src/GameIdeas/GameIdeas.Shared/Dto/CategoriesDto.cs
index 54d6ada..922b3bd 100644
--- a/src/GameIdeas/GameIdeas.Shared/Dto/CategoriesDto.cs
+++ b/src/GameIdeas/GameIdeas.Shared/Dto/CategoriesDto.cs
@@ -8,5 +8,5 @@ public class CategoriesDto
public List? Developers { get; set; }
public List? Publishers { get; set; }
public List? ReleaseYears { get; set; }
- public List? StorageSpaces { get; set; }
+ public List? StorageSpaces { get; set; }
}
diff --git a/src/GameIdeas/GameIdeas.Shared/Dto/UserDto.cs b/src/GameIdeas/GameIdeas.Shared/Dto/UserDto.cs
index e2ffd7a..a23a5dd 100644
--- a/src/GameIdeas/GameIdeas.Shared/Dto/UserDto.cs
+++ b/src/GameIdeas/GameIdeas.Shared/Dto/UserDto.cs
@@ -1,6 +1,4 @@
-using GameIdeas.Shared.Enum;
-
-namespace GameIdeas.Shared.Dto;
+namespace GameIdeas.Shared.Dto;
public class UserDto
{
diff --git a/src/GameIdeas/GameIdeas.Shared/Model/Game.cs b/src/GameIdeas/GameIdeas.Shared/Model/Game.cs
index fee8508..fa7bf9a 100644
--- a/src/GameIdeas/GameIdeas.Shared/Model/Game.cs
+++ b/src/GameIdeas/GameIdeas.Shared/Model/Game.cs
@@ -31,4 +31,3 @@ public partial class Game
public virtual ICollection GameProperties { get; set; }
public virtual ICollection GameTags { get; set; }
}
-
\ No newline at end of file
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Context/GameIdeasContext.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Context/GameIdeasContext.cs
index ece2f8c..591c43e 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Context/GameIdeasContext.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Context/GameIdeasContext.cs
@@ -6,7 +6,7 @@ namespace GameIdeas.WebAPI.Context;
public class GameIdeasContext : IdentityDbContext
{
- public GameIdeasContext(DbContextOptions option)
+ public GameIdeasContext(DbContextOptions option)
: base(option)
{
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
@@ -25,14 +25,16 @@ public class GameIdeasContext : IdentityDbContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
- modelBuilder.Entity(entity => {
+ modelBuilder.Entity(entity =>
+ {
entity.ToTable("Developer");
entity.HasIndex(e => e.Name)
.IsUnique();
});
- modelBuilder.Entity(entity => {
+ modelBuilder.Entity(entity =>
+ {
entity.ToTable("Platform");
entity.HasIndex(e => e.Label)
@@ -41,18 +43,18 @@ public class GameIdeasContext : IdentityDbContext
modelBuilder.Entity(entity =>
{
- entity.ToTable("Property");
-
+ entity.ToTable("Property");
+
entity.HasIndex(e => e.Label)
.IsUnique();
});
- modelBuilder.Entity(entity =>
- {
- entity.ToTable("Publisher");
+ modelBuilder.Entity(entity =>
+ {
+ entity.ToTable("Publisher");
entity.HasIndex(e => e.Name)
- .IsUnique();
+ .IsUnique();
});
modelBuilder.Entity(entity =>
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/GameController.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/GameController.cs
index f747635..8ec0eac 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/GameController.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/GameController.cs
@@ -11,7 +11,7 @@ namespace GameIdeas.WebAPI.Controllers;
public class GameController(
IGameReadService gameReadService,
- IGameWriteService gameWriteService,
+ IGameWriteService gameWriteService,
ILoggerFactory loggerFactory) : Controller
{
private readonly ILogger logger = loggerFactory.CreateLogger();
@@ -73,7 +73,7 @@ public class GameController(
{
logger.LogError(e, "Internal error while update game");
return StatusCode(500, e.Message);
- }
+ }
}
[Authorize(Roles = GlobalConstants.ADMIN_MEMBER)]
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/TranslationsController.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/TranslationsController.cs
index 4fdabc4..3378d73 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/TranslationsController.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/TranslationsController.cs
@@ -5,32 +5,32 @@ namespace GameIdeas.WebAPI.Controllers;
[ApiController]
[Route("api/[controller]")]
-public class TranslationsController (ILogger Logger) : ControllerBase
+public class TranslationsController(ILogger Logger) : ControllerBase
{
[HttpGet]
- public async Task GetTranslations()
- {
- var dictionary = new Dictionary();
+ public async Task GetTranslations()
+ {
+ var dictionary = new Dictionary();
- try
- {
- var filesDirectory = Path.Combine(
- Directory.GetCurrentDirectory(),
- "Files");
- var translationFiles = Directory.GetFiles(filesDirectory, "*.json");
- foreach (var file in translationFiles)
- {
- var name = file.Split('.');
- var culture = name[^2];
- var content = await System.IO.File.ReadAllTextAsync(file);
- dictionary.Add(culture, content);
- }
- }
- catch(Exception ex)
- {
- Logger.LogError(ex, "Internal translations error");
- }
+ try
+ {
+ var filesDirectory = Path.Combine(
+ Directory.GetCurrentDirectory(),
+ "Files");
+ var translationFiles = Directory.GetFiles(filesDirectory, "*.json");
+ foreach (var file in translationFiles)
+ {
+ var name = file.Split('.');
+ var culture = name[^2];
+ var content = await System.IO.File.ReadAllTextAsync(file);
+ dictionary.Add(culture, content);
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex, "Internal translations error");
+ }
- return Ok(dictionary);
- }
+ return Ok(dictionary);
+ }
}
\ No newline at end of file
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/UserController.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/UserController.cs
index 90a03ac..4266b7d 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/UserController.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/UserController.cs
@@ -19,22 +19,22 @@ public class UserController(
[HttpPost("Login")]
public async Task> Login([FromBody] UserDto model)
{
- try
- {
+ try
+ {
return Ok(await userReadService.Login(model));
- }
- catch (UserInvalidException e)
- {
+ }
+ catch (UserInvalidException e)
+ {
logger.LogInformation(e, "Missing informations for authentication");
return StatusCode(406, e.Message);
}
- catch (UserUnauthorizedException e)
+ catch (UserUnauthorizedException e)
{
logger.LogWarning(e, "Authentication invalid with there informations");
return Unauthorized(e.Message);
}
catch (Exception e)
- {
+ {
logger.LogError(e, "Internal error while search games");
return StatusCode(500, e.Message);
}
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Exceptions/UserInvalidException.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Exceptions/UserInvalidException.cs
index a1ddfca..a5ca0c0 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Exceptions/UserInvalidException.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Exceptions/UserInvalidException.cs
@@ -1,3 +1,3 @@
namespace GameIdeas.WebAPI.Exceptions;
-public class UserInvalidException (string message) : Exception(message);
+public class UserInvalidException(string message) : Exception(message);
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420153030_InitialCreate.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420153030_InitialCreate.cs
index e754733..255f72c 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420153030_InitialCreate.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420153030_InitialCreate.cs
@@ -1,5 +1,4 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420160158_SeedDefaultUser.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420160158_SeedDefaultUser.cs
index 2a321a9..0709d4a 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420160158_SeedDefaultUser.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420160158_SeedDefaultUser.cs
@@ -54,7 +54,7 @@ namespace GameIdeas.WebAPI.Migrations
///
protected override void Down(MigrationBuilder migrationBuilder)
{
- migrationBuilder.Sql(@$"DELETE FROM ""AspNetUserRoles"" WHERE ""UserId"" = '{GlobalConstants.ADMINISTRATOR_USER_ID.ToString()}' AND ""RoleId"" = '{GlobalConstants.ADMINISTRATOR_ID.ToString()}'");
+ migrationBuilder.Sql(@$"DELETE FROM ""AspNetUserRoles"" WHERE ""UserId"" = '{GlobalConstants.ADMINISTRATOR_USER_ID}' AND ""RoleId"" = '{GlobalConstants.ADMINISTRATOR_ID}'");
migrationBuilder.DeleteData("AspNetUsers", "Id", GlobalConstants.ADMINISTRATOR_USER_ID.ToString());
migrationBuilder.DeleteData("AspNetRoles", "Id", GlobalConstants.ADMINISTRATOR_ID.ToString());
migrationBuilder.DeleteData("AspNetRoles", "Id", GlobalConstants.MEMBER_ID.ToString());
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Program.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Program.cs
index 7fd6668..6f1e4e2 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Program.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Program.cs
@@ -39,7 +39,7 @@ services.AddIdentity()
.AddDefaultTokenProviders();
var jwtKey = Environment.GetEnvironmentVariable("JWT_KEY")
- ?? throw new ArgumentNullException(message: "Invalid key for JWT token", null);
+ ?? throw new ArgumentNullException(message: "Invalid key for JWT token", null);
services.AddAuthentication(options =>
{
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Games/GameReadService.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Games/GameReadService.cs
index aefaf0d..3320f74 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Games/GameReadService.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Games/GameReadService.cs
@@ -60,7 +60,7 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
Expression propertyAccess = Expression.PropertyOrField(param, filter.SortPropertyName);
var converted = Expression.Convert(propertyAccess, typeof(object));
var lambda = Expression.Lambda>(converted, param);
-
+
if (filter.SortType == Shared.Enum.SortType.Ascending)
{
query = Queryable.OrderBy(query, lambda);
@@ -116,7 +116,7 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
if (filter.ReleaseYears != null)
{
- query = query.Where(game => game.ReleaseDate != null &&
+ query = query.Where(game => game.ReleaseDate != null &&
filter.ReleaseYears.Contains(game.ReleaseDate.Value.Year));
}
}
@@ -130,15 +130,14 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
.Select(k => k.Trim())
.ToArray() ?? [];
- games = games
+ games = [.. games
.Where(game => keywords.All(
kw => game.Title.Contains(kw, StringComparison.OrdinalIgnoreCase)
))
.OrderBy(game => keywords.Min(kw =>
game.Title.IndexOf(kw, StringComparison.OrdinalIgnoreCase)
))
- .ThenBy(game => game.Title.Length)
- .ToList();
+ .ThenBy(game => game.Title.Length)];
return;
}
@@ -147,10 +146,9 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
{
var storageSpaces = categoryService.GetStorageSpaces().Where(stor => filter.StorageSpaces.Contains(stor.Id));
- games = games
+ games = [.. games
.Where(game => storageSpaces.Any(stor =>
- (stor.MinSize ?? int.MinValue) <= game.StorageSpace && (stor.MaxSize ?? int.MaxValue) > game.StorageSpace))
- .ToList();
+ (stor.MinSize ?? int.MinValue) <= game.StorageSpace && (stor.MaxSize ?? int.MaxValue) > game.StorageSpace))];
}
}
}
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserReadService.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserReadService.cs
index f60d4bb..1c377fa 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserReadService.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserReadService.cs
@@ -91,15 +91,14 @@ public class UserReadService(
.Select(k => k.Trim())
.ToArray() ?? [];
- users = users
+ users = [.. users
.Where(user => keywords.All(
kw => user.UserName?.Contains(kw, StringComparison.OrdinalIgnoreCase) ?? true
))
.OrderBy(user => keywords.Min(kw =>
user.UserName?.IndexOf(kw, StringComparison.OrdinalIgnoreCase)
))
- .ThenBy(user => user.UserName?.Length)
- .ToList();
+ .ThenBy(user => user.UserName?.Length)];
}
}
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserWriteService.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserWriteService.cs
index 88c4524..5a7f041 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserWriteService.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserWriteService.cs
@@ -1,5 +1,4 @@
-using AutoMapper;
-using GameIdeas.Resources;
+using GameIdeas.Resources;
using GameIdeas.Shared.Dto;
using GameIdeas.Shared.Model;
using GameIdeas.WebAPI.Exceptions;
@@ -12,8 +11,8 @@ public class UserWriteService(
{
public async Task CreateUser(UserDto user)
{
- if (user.Username == null ||
- user.Password == null ||
+ if (user.Username == null ||
+ user.Password == null ||
user.Role == null)
{
throw new UserInvalidException(ResourcesKey.MissingField);
@@ -75,7 +74,7 @@ public class UserWriteService(
{
var roles = await userManager.GetRolesAsync(userToUpdate);
await userManager.RemoveFromRolesAsync(userToUpdate, roles);
- await userManager.AddToRoleAsync(userToUpdate, user.Role.Name);
+ await userManager.AddToRoleAsync(userToUpdate, user.Role.Name);
}
return userToUpdate.Id;