Fix merge
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 38s

This commit is contained in:
2025-05-18 16:59:59 +02:00
38 changed files with 281 additions and 197 deletions

View File

@@ -4,9 +4,3 @@
<div class="page">
@Body
</div>
<div class="background">
<span class="orb red"></span>
<span class="orb blue"></span>
<span class="orb green"></span>
</div>

View File

@@ -3,46 +3,3 @@
flex-direction: column;
height: 100%;
}
.orb {
position: absolute;
border-radius: 100%;
z-index: var(--index-orb);
}
.green {
width: 80vh;
height: 80vh;
top: -20vh;
background: #315941;
filter: blur(30vh);
}
.blue {
width: 80vw;
height: 80vw;
left: 10vw;
top: 50vh;
background: #3A4156;
filter: blur(30vh);
}
.red {
width: 100vh;
height: 100vh;
left: 60vw;
top: -40vh;
background: #593533;
filter: blur(30vh);
}
.background {
height: 100vh;
width: 100vw;
background: var(--background);
position: fixed;
overflow: hidden;
top: 0;
left: 0;
z-index: var(--index-background);
}

View File

@@ -22,7 +22,7 @@ public partial class GameDetail : GameBaseComponent
private void HandleSubmitNewGame()
{
NavigationManager.NavigateTo("/");
NavigationManager.NavigateTo("/Games");
}
private async Task FetchGameDetail()
@@ -30,6 +30,7 @@ public partial class GameDetail : GameBaseComponent
try
{
IsLoading = true;
StateHasChanged();
Game = await GameGateway.GetGameById(GameId);
}
@@ -40,6 +41,7 @@ public partial class GameDetail : GameBaseComponent
finally
{
IsLoading = false;
StateHasChanged();
}
}
}

View File

@@ -59,6 +59,7 @@ public partial class GameCreationForm
try
{
IsLoading = true;
StateHasChanged();
int gameId;
var authState = await AuthenticationState.GetAuthenticationStateAsync();
@@ -108,6 +109,7 @@ public partial class GameCreationForm
try
{
IsLoading = true;
StateHasChanged();
GameDto = await GameGateway.GetGameById(gameId);
}
@@ -118,9 +120,8 @@ public partial class GameCreationForm
finally
{
IsLoading = false;
}
EditContext = new(GameDto);
StateHasChanged();
}
}
}

View File

@@ -34,6 +34,7 @@
grid-column: 2;
box-sizing: border-box;
color: var(--white);
padding: 0 8px;
}
::deep input[type="date"]::-webkit-calendar-picker-indicator {

View File

@@ -97,15 +97,3 @@
display: none;
}
}
@keyframes loading {
0% {
background: rgb(255, 255, 255, 0.05);
}
50% {
background: rgb(255, 255, 255, 0.2);
}
100% {
background: rgb(255, 255, 255, 0.05);
}
}

View File

@@ -4,6 +4,8 @@
@using GameIdeas.BlazorApp.Shared.Constants
@using GameIdeas.Shared.Dto
<NavigationLock OnBeforeInternalNavigation="HandleLocationChanged" />
<div class="advanced-filter-container" style="@(ExpandedFilter ? "display: flex" : "")">
<span class="title">@ResourcesKey.Filters</span>
@@ -27,15 +29,15 @@
<SelectSearch TItem="int" Placeholder="@ResourcesKey.ReleaseDate" GetLabel="@(p => p.ToString())"
@bind-Values=GameFilter.ReleaseYears @bind-Values:after=HandleValueChanged Theme="Theme" Items="Categories?.ReleaseYears" />
<SelectSearch TItem="int" Placeholder="@ResourcesKey.StorageSize" GetLabel="@GetStorageSpaceLabel"
<SelectSearch TItem="int" Placeholder="@ResourcesKey.StorageSize" GetLabel="@GetStorageSpaceLabel" OrderBy="@(item => item.ToString())"
@bind-Values=GameFilter.StorageSpaceIds @bind-Values:after=HandleValueChanged Theme="Theme" Items="@(Categories?.StorageSpaces?.Select(stor => stor.Id).ToList())" />
<span class="title">@ResourcesKey.LastAdd</span>
</div>
<button type="button" class="open-filter" @onclick=HandleExpandFilter>
<button type="button" class="open-filter" @onclick=HandleExpandFilterAsync>
@Icons.Filter
</button>
<BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClicked" CloseOnClick="true"
<BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClickedAsync" CloseOnClick="true"
AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" />

View File

@@ -4,6 +4,7 @@ using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using GameIdeas.Resources;
using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
namespace GameIdeas.BlazorApp.Pages.Games.Filter;
@@ -48,13 +49,24 @@ public partial class AdvancedGameFilter
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
}
private void HandleExpandFilter(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
private void HandleExpandFilterAsync(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
{
ExpandedFilter = true;
BackdropFilter?.Show();
}
private void HandleBackdropFilterClicked()
private void HandleBackdropFilterClickedAsync()
{
ExpandedFilter = false;
}
private void HandleLocationChanged(LocationChangingContext locationContext)
{
if (ExpandedFilter)
{
ExpandedFilter = false;
BackdropFilter?.Hide();
locationContext.PreventNavigation();
}
}
}

View File

@@ -1,4 +1,4 @@
@page "/"
@page "/Games"
@using GameIdeas.BlazorApp.Pages.Games.Components
@using GameIdeas.BlazorApp.Pages.Games.Filter
@using GameIdeas.BlazorApp.Shared.Components
@@ -23,12 +23,22 @@
<div class="content">
@if (!IsLoading)
{
@foreach (var game in GamesDto)
@if (GamesDto.NumberOfGames != 0)
{
<div class="games-number">@string.Format(ResourcesKey.GamesNumberFormat, GamesDto.NumberOfGames)</div>
@foreach (var game in GamesDto.Games)
{
<GameRow GameDto="game" OnDelete="HandleDeleteGame" OnEdit="HandleEditGame" />
}
}
else
{
<div class="no-games">@ResourcesKey.NoGames</div>
}
}
else
{
@for (int i = 0; i < 20; i++)
{

View File

@@ -12,7 +12,7 @@ public partial class Games : GameBaseComponent
{
private DisplayType DisplayType = DisplayType.List;
private GameFilterParams GameFilter = new();
private IEnumerable<GameDto> GamesDto = [];
private GameListDto GamesDto = new();
private int CurrentPage;
private Popup? DeletePopup;
private GameDto? GameToDelete;
@@ -37,6 +37,7 @@ public partial class Games : GameBaseComponent
try
{
IsLoading = displayLoader;
StateHasChanged();
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
}
@@ -47,6 +48,7 @@ public partial class Games : GameBaseComponent
finally
{
IsLoading = false;
StateHasChanged();
}
}
private async Task HandleFilterChanged(GameFilterParams args)
@@ -91,6 +93,7 @@ public partial class Games : GameBaseComponent
try
{
IsLoading = true;
StateHasChanged();
await GameGateway.DeleteGame(GameToDelete?.Id ?? 0);
await HandleFetchDatas(false);

View File

@@ -35,7 +35,7 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
}
}
public async Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filterParams, int currentPage)
public async Task<GameListDto> FetchGames(GameFilterParams filterParams, int currentPage)
{
try
{
@@ -52,9 +52,11 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
PropertyIds = filterParams.Properties?.Select(d => d.Id ?? 0).ToList(),
ReleaseYears = filterParams.ReleaseYears,
TagIds = filterParams.Tags?.Select(d => d.Id ?? 0).ToList(),
SortPropertyName = filterParams.SortProperty?.PropertyName,
SortType = filterParams.SortType?.SortType
};
var result = await httpClientService.FetchDataAsync<IEnumerable<GameDto>>(Endpoints.Game.Fetch(filter));
var result = await httpClientService.FetchDataAsync<GameListDto>(Endpoints.Game.Fetch(filter));
return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchGames);
}
catch (Exception)

View File

@@ -7,7 +7,7 @@ public interface IGameGateway
{
Task<CategoriesDto> FetchCategories();
Task<int> CreateGame(GameDetailDto game);
Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filter, int currentPage);
Task<GameListDto> FetchGames(GameFilterParams filter, int currentPage);
Task<GameDetailDto> GetGameById(int gameId);
Task<bool> DeleteGame(int gameIdToDelete);
Task<int> UpdateGame(GameDetailDto gameDto);

View File

@@ -0,0 +1,10 @@
@page "/"
@inject NavigationManager navigationManager
@code {
protected override void OnInitialized()
{
navigationManager.NavigateTo("/Games");
}
}

View File

@@ -28,6 +28,8 @@ public partial class Login
try
{
IsLoading = true;
StateHasChanged();
await AuthGateway.Login(UserDto);
}
catch (Exception)

View File

@@ -50,6 +50,6 @@
border-radius: 50%;
border: 3px solid rgba(0, 0, 0, 0.2);
border-top-color: var(--white);
animation: loading 1s linear infinite;
animation: spin 1s linear infinite;
justify-self: center;
}

View File

@@ -14,7 +14,7 @@ public partial class UserMenu
{
ContentVisile = false;
await AuthGateway.Logout();
NavigationManager.NavigateTo("/");
NavigationManager.NavigateTo("/Games");
}
private void HandleAccountClicked()

View File

@@ -54,16 +54,3 @@
fill: var(--yellow);
}
@keyframes loading {
0% {
background: rgb(255, 255, 255, 0.05);
}
50% {
background: rgb(255, 255, 255, 0.2);
}
100% {
background: rgb(255, 255, 255, 0.05);
}
}

View File

@@ -28,12 +28,21 @@
<div class="content">
@if (!IsLoading)
{
@if (UserList.UsersCount != 0)
{
<div class="user-number">@string.Format(ResourcesKey.UsersNumberFormat, UserList.UsersCount)</div>
@foreach (var user in UserList.Users ?? [])
{
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" CanDelete=@(user.Id != currentUserId) />
}
}
else
{
<div class="no-users">@ResourcesKey.NoUsers</div>
}
}
else
{
@for (int i = 0; i < 20; i++)
{

View File

@@ -36,18 +36,17 @@ public partial class Users
}
await FetchData();
await FetchUsers();
await FetchRoles();
await base.OnInitializedAsync();
}
private async Task FetchData(bool fetchRoles = true)
private async Task FetchUsers(bool displayLoading = true)
{
try
{
IsLoading = true;
if (fetchRoles)
Roles = await UserGateway.GetRoles();
IsLoading = displayLoading;
StateHasChanged();
UserList = await UserGateway.GetUsers(FilterParams, CurrentPage);
}
@@ -58,6 +57,27 @@ public partial class Users
finally
{
IsLoading = false;
StateHasChanged();
}
}
private async Task FetchRoles()
{
try
{
IsLoading = true;
StateHasChanged();
Roles = await UserGateway.GetRoles();
}
catch (Exception)
{
throw;
}
finally
{
IsLoading = false;
StateHasChanged();
}
}
@@ -66,9 +86,10 @@ public partial class Users
try
{
IsLoading = true;
StateHasChanged();
await UserGateway.CreateUser(user);
await FetchData(false);
await FetchUsers();
}
catch (Exception)
{
@@ -77,19 +98,20 @@ public partial class Users
finally
{
IsLoading = false;
}
StateHasChanged();
UserAdd = new();
}
}
private async Task HandleUpdateUser(UserDto user)
{
try
{
IsLoading = true;
StateHasChanged();
await UserGateway.UpdateUser(user);
await FetchData(false);
await FetchUsers();
}
catch (Exception)
{
@@ -98,6 +120,7 @@ public partial class Users
finally
{
IsLoading = false;
StateHasChanged();
}
}
@@ -113,9 +136,10 @@ public partial class Users
try
{
IsLoading = true;
StateHasChanged();
await UserGateway.DeleteUser(UserDelete.Id);
await FetchData(false);
await FetchUsers();
}
catch (Exception)
{
@@ -124,6 +148,7 @@ public partial class Users
finally
{
IsLoading = false;
StateHasChanged();
}
UserDelete = null;
@@ -134,7 +159,7 @@ public partial class Users
}
private async Task HandleFilterChanged()
{
await FetchData(false);
await FetchUsers(false);
}
private void HandleCancelPopupClicked()
{

View File

@@ -19,13 +19,3 @@
height: 60px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@@ -24,6 +24,7 @@ public class GameBaseComponent : ComponentBase
try
{
IsLoading = true;
StateHasChanged();
Categories = await GameGateway.FetchCategories();
}
@@ -34,6 +35,7 @@ public class GameBaseComponent : ComponentBase
finally
{
IsLoading = false;
StateHasChanged();
}
}

View File

@@ -34,6 +34,7 @@
min-width: 18px;
height: 18px;
width: 18px;
z-index: 800;
}
.clear-icon:hover {

View File

@@ -4,8 +4,10 @@ public class SelectParams<TItem, THeader>
{
public List<TItem> Items { get; set; } = [];
public Func<TItem, string> GetItemLabel { get; set; } = _ => string.Empty;
public Func<TItem, string>? GetItemOrder { get; set; }
public List<THeader> Headers { get; set; } = [];
public Func<THeader, string> GetHeaderLabel { get; set; } = _ => string.Empty;
public Func<THeader, string>? GetHeaderOrder { get; set; }
public Func<string, TItem>? AddItem { get; set; }
}

View File

@@ -27,7 +27,7 @@
@if (Params.Headers != null)
{
@foreach (var header in (HeaderValues ?? []).UnionBy(Params.Headers, Params.GetHeaderLabel))
@foreach (var header in GetHeaders())
{
<SelectRow IsSelected=@(HeaderValues?.Contains(header))
Label="@Params.GetHeaderLabel(header)" Theme=Theme
@@ -42,7 +42,7 @@
@if (Params.Items != null)
{
@foreach (var item in (Values ?? []).UnionBy(Params.Items, Params.GetItemLabel))
@foreach (var item in GetItems())
{
<SelectRow IsSelected=@(Values?.Contains(item))
Label="@Params.GetItemLabel(item)" Theme=Theme

View File

@@ -101,4 +101,12 @@ public partial class Select<TItem, THeader>
await ValuesChanged.InvokeAsync(Values);
}
}
private List<THeader> GetHeaders() => [.. (HeaderValues ?? [])
.UnionBy(Params.Headers, Params.GetHeaderLabel)
.OrderBy(Params.GetHeaderOrder ?? Params.GetHeaderLabel)];
private List<TItem> GetItems() => [.. (Values ?? [])
.UnionBy(Params.Items, Params.GetItemLabel)
.OrderBy(Params.GetItemOrder ?? Params.GetItemLabel)];
}

View File

@@ -22,8 +22,6 @@
overflow: hidden;
display: flex;
flex-direction: column;
animation-name: fade-in;
animation-duration: 0.2s;
}
.line {

View File

@@ -5,12 +5,12 @@
@typeparam TItem
<Select @ref=Select TItem="TItem" THeader="string" Theme="Theme" Type="SelectType"
<Select @ref=Select TItem="TItem" THeader="string" Theme="Theme" Type="SelectType" DisableClicked=true
Params="SelectParams" Values=Values ValuesChanged="HandleValuesChanged" QuickAdd=QuickAdd>
<div class="@SelectHelper.GetClassFromTheme(Theme)">
<SearchInput @ref=SearchInput Icon="SearchInputIcon.Dropdown" Placeholder="@Placeholder"
TextChanged="HandleClearClicked" ClearClicked="HandleClearClicked" IsDisable=QuickAdd
TextChanged="HandleTextChanged" ClearClicked="HandleClearClicked" IsDisable=false
FocusIn="HandleFocusIn" SearchClicked="HandleFocusIn" />
</div>

View File

@@ -1,3 +1,4 @@
using GameIdeas.BlazorApp.Pages.Games;
using GameIdeas.BlazorApp.Shared.Components.Search;
using GameIdeas.BlazorApp.Shared.Components.Select;
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
@@ -10,6 +11,7 @@ public partial class SelectSearch<TItem>
[Parameter] public SelectTheme Theme { get; set; }
[Parameter] public List<TItem> Items { get; set; } = [];
[Parameter] public Func<TItem, string> GetLabel { get; set; } = _ => string.Empty;
[Parameter] public Func<TItem, string>? OrderBy { get; set; }
[Parameter] public List<TItem> Values { get; set; } = [];
[Parameter] public EventCallback<List<TItem>> ValuesChanged { get; set; }
[Parameter] public string Placeholder { get; set; } = string.Empty;
@@ -27,6 +29,7 @@ public partial class SelectSearch<TItem>
{
Items = Items,
GetItemLabel = GetLabel,
GetItemOrder = OrderBy,
AddItem = AddItem
};
@@ -35,7 +38,7 @@ public partial class SelectSearch<TItem>
protected override void OnAfterRender(bool firstRender)
{
if (Values != null)
if (firstRender && Values != null)
{
SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel)));
}

View File

@@ -82,62 +82,18 @@ html, body, #app {
}
.loading-progress {
position: relative;
display: block;
width: 8rem;
height: 8rem;
margin: 20vh auto 1rem auto;
display: flex;
width: 100vw;
height: 100vh;
justify-content: center;
align-items: center;
animation: loading-background 4s linear infinite;
}
.loading-progress circle {
fill: none;
stroke: #e0e0e0;
stroke-width: 0.6rem;
transform-origin: 50% 50%;
transform: rotate(-90deg);
}
.loading-progress circle:last-child {
stroke: #1b6ec2;
stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
color: #000;
position: absolute;
text-align: center;
font-weight: bold;
inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text:after {
content: var(--blazor-load-percentage-text, "Loading");
}
code {
color: #c02d76;
}
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
color: var(--bs-secondary-color);
text-align: end;
}
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
text-align: start;
}
:focus-visible {
outline: none;
}
.expand-col-2 {
grid-column: 1 / 3;
}
.expand-row-2 {
grid-row: 1 / 3;
.loading-progress > #loading-icon {
max-width: 200px;
max-height: 200px;
animation: loading-icon 4s ease-in-out infinite;
}
.body-sm {
@@ -158,14 +114,59 @@ code {
text-decoration: none;
}
:focus-visible {
outline: none;
}
@keyframes fade-in {
0% {opacity: 0}
100% {opacity: 1}
@keyframes loading-background {
0% {
background: rgb(0, 0, 0, 0.2);
}
50% {
background: rgb(0, 0, 0, 0.3);
}
100% {
background: rgb(0, 0, 0, 0.2);
}
}
@keyframes loading-icon {
0% {
transform: scale(1);
}
50% {
transform: scale(0.95);
}
100% {
transform: scale(1);
}
}
@keyframes loading {
to {
0% {
background: rgb(255, 255, 255, 0.05);
}
50% {
background: rgb(255, 255, 255, 0.2);
}
100% {
background: rgb(255, 255, 255, 0.05);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@@ -0,0 +1,42 @@
.orb {
position: absolute;
border-radius: 100%;
z-index: var(--index-orb);
}
.green {
width: 80vh;
height: 80vh;
top: -20vh;
background: #315941;
filter: blur(30vh);
}
.blue {
width: 80vw;
height: 80vw;
left: 10vw;
top: 50vh;
background: #3A4156;
filter: blur(30vh);
}
.red {
width: 100vh;
height: 100vh;
left: 60vw;
top: -40vh;
background: #593533;
filter: blur(30vh);
}
#background {
height: 100vh;
width: 100vw;
background: var(--background);
position: fixed;
overflow: hidden;
top: 0;
left: 0;
z-index: var(--index-background);
}

View File

@@ -7,17 +7,22 @@
<title>Game Ideas</title>
<base href="/" />
<link rel="stylesheet" href="css/app.css" />
<link rel="stylesheet" href="css/background.css" />
<link rel="icon" type="image/png" href="icon.png" />
<link href="GameIdeas.BlazorApp.styles.css" rel="stylesheet" />
</head>
<body>
<div id="app">
<svg class="loading-progress">
<circle r="40%" cx="50%" cy="50%" />
<circle r="40%" cx="50%" cy="50%" />
</svg>
<div class="loading-progress-text"></div>
<div class="loading-progress">
<img src="icon.png" alt="" id="loading-icon">
</div>
</div>
<div id="background">
<span class="orb red"></span>
<span class="orb blue"></span>
<span class="orb green"></span>
</div>
<div id="blazor-error-ui">
@@ -25,6 +30,7 @@
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script src="Shared/Components/BackdropFilter/BackdropFilter.razor.js"></script>
<script src="Pages/Games/Components/GameCreationForm.razor.js"></script>

View File

@@ -74,6 +74,10 @@ public class Translations (TranslationService translationService)
public string Detail => translationService.Translate(nameof(Detail));
public string Edit => translationService.Translate(nameof(Edit));
public string Delete => translationService.Translate(nameof(Delete));
public string NoGames => translationService.Translate(nameof(NoGames));
public string NoUsers => translationService.Translate(nameof(NoUsers));
public string GamesNumberFormat => translationService.Translate(nameof(GamesNumberFormat));
public string UsersNumberFormat => translationService.Translate(nameof(UsersNumberFormat));
}
public static class ResourcesKey
@@ -156,4 +160,8 @@ public static class ResourcesKey
public static string Detail => _instance?.Detail ?? throw new InvalidOperationException("ResourcesKey.Detail is not initialized.");
public static string Edit => _instance?.Edit ?? throw new InvalidOperationException("ResourcesKey.Edit is not initialized.");
public static string Delete => _instance?.Delete ?? throw new InvalidOperationException("ResourcesKey.Delete is not initialized.");
public static string NoGames => _instance?.NoGames ?? throw new InvalidOperationException("ResourcesKey.NoGames is not initialized.");
public static string NoUsers => _instance?.NoUsers ?? throw new InvalidOperationException("ResourcesKey.NoUsers is not initialized.");
public static string GamesNumberFormat => _instance?.GamesNumberFormat ?? throw new InvalidOperationException("ResourcesKey.GamesNumberFormat is not initialized.");
public static string UsersNumberFormat => _instance?.UsersNumberFormat ?? throw new InvalidOperationException("ResourcesKey.UsersNumberFormat is not initialized.");
}

View File

@@ -0,0 +1,7 @@
namespace GameIdeas.Shared.Dto;
public class GameListDto
{
public IEnumerable<GameDto> Games { get; set; } = [];
public int NumberOfGames { get; set; }
}

View File

@@ -17,7 +17,7 @@ public class GameController(
private readonly ILogger<GameController> logger = loggerFactory.CreateLogger<GameController>();
[HttpGet]
public async Task<ActionResult<IEnumerable<GameDto>>> SearchGames([FromQuery] GameFilterDto filter)
public async Task<ActionResult<GameListDto>> SearchGames([FromQuery] GameFilterDto filter)
{
try
{

View File

@@ -69,5 +69,9 @@
"ReadLess": "Réduire",
"Detail": "Détail",
"Edit": "Modifier",
"Delete": "Supprimer"
"Delete": "Supprimer",
"NoGames": "Pas de jeux disponible",
"NoUsers": "Pas d'utilisateurs disponible",
"GamesNumberFormat": "Nombre de jeux : {0}",
"UsersNumberFormat": "Nombre d'utilisateurs : {0}"
}

View File

@@ -12,7 +12,7 @@ namespace GameIdeas.WebAPI.Services.Games;
public class GameReadService(GameIdeasContext context, IMapper mapper, ICategoryService categoryService) : IGameReadService
{
public async Task<IEnumerable<GameDto>> GetGames(GameFilterDto filter)
public async Task<GameListDto> GetGames(GameFilterDto filter)
{
var query = context.Games
.Include(g => g.GamePlatforms).ThenInclude(gp => gp.Platform)
@@ -26,13 +26,19 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
ApplyOrder(ref query, filter);
var games = await query.Skip((filter.CurrentPage - 1) * GlobalConstants.NUMBER_PER_PAGE)
.Take(GlobalConstants.NUMBER_PER_PAGE)
.ToListAsync();
var games = await query.ToListAsync();
ApplyStaticFilter(ref games, filter);
return mapper.Map<IEnumerable<GameDto>>(games);
games = [.. games
.Skip((filter.CurrentPage - 1) * GlobalConstants.NUMBER_PER_PAGE)
.Take(GlobalConstants.NUMBER_PER_PAGE)];
return new()
{
Games = mapper.Map<IEnumerable<GameDto>>(games),
NumberOfGames = games.Count
};
}
public async Task<GameDetailDto> GetGameById(int gameId)

View File

@@ -4,6 +4,6 @@ namespace GameIdeas.WebAPI.Services.Games;
public interface IGameReadService
{
Task<IEnumerable<GameDto>> GetGames(GameFilterDto filter);
Task<GameListDto> GetGames(GameFilterDto filter);
Task<GameDetailDto> GetGameById(int gameId);
}

View File

@@ -33,9 +33,10 @@ public class UserReadService(
.OrderBy(u => u.UserName)
.ToListAsync();
var count = users.Count;
ApplyStaticFilter(ref users, filter);
var count = users.Count;
var usersDto = mapper.Map<IEnumerable<UserDto>>(users);
usersDto = await ApplyRoles(usersDto, filter);