Add release date and storage filter
All checks were successful
Game Ideas build for PR / build_blazor_app (pull_request) Successful in 34s
All checks were successful
Game Ideas build for PR / build_blazor_app (pull_request) Successful in 34s
This commit is contained in:
@@ -22,4 +22,19 @@ public static class GameHelper
|
|||||||
_ => "--yellow",
|
_ => "--yellow",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetFormatedStorageSpace(double? storageValue)
|
||||||
|
{
|
||||||
|
if (storageValue == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return storageValue switch
|
||||||
|
{
|
||||||
|
>= 1000000 => $"{storageValue / 1000000:f1} To",
|
||||||
|
>= 1000 => $"{storageValue / 1000:f1} Go",
|
||||||
|
_ => $"{storageValue:f1} Mo"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,19 +12,4 @@ public class GameBase : ComponentBase
|
|||||||
{
|
{
|
||||||
NavigationManager.NavigateTo($"/Games/Detail/{GameDto.Id}");
|
NavigationManager.NavigateTo($"/Games/Detail/{GameDto.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string GetFormatedStorageSpace()
|
|
||||||
{
|
|
||||||
if (GameDto.StorageSpace == null)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GameDto.StorageSpace switch
|
|
||||||
{
|
|
||||||
>= 1000000 => $"{GameDto.StorageSpace / 1000000:f1} To",
|
|
||||||
>= 1000 => $"{GameDto.StorageSpace / 1000:f1} Go",
|
|
||||||
_ => $"{GameDto.StorageSpace:f1} Mo"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="storage">@GetFormatedStorageSpace()</span>
|
<span class="storage">@GameHelper.GetFormatedStorageSpace(GameDto.StorageSpace)</span>
|
||||||
|
|
||||||
<div class="interest">
|
<div class="interest">
|
||||||
<span class="value" style="@($"color: var({GameHelper.GetInterestColor(GameDto.Interest, 5)})")">
|
<span class="value" style="@($"color: var({GameHelper.GetInterestColor(GameDto.Interest, 5)})")">
|
||||||
|
|||||||
@@ -22,5 +22,11 @@
|
|||||||
<SelectSearch TItem="PublisherDto" Placeholder="@ResourcesKey.Publishers" GetLabel="@(p => p.Name)"
|
<SelectSearch TItem="PublisherDto" Placeholder="@ResourcesKey.Publishers" GetLabel="@(p => p.Name)"
|
||||||
@bind-Values=GameFilter.Publishers @bind-Values:after=HandleValueChanged Theme="Theme" Items="Categories?.Publishers" />
|
@bind-Values=GameFilter.Publishers @bind-Values:after=HandleValueChanged Theme="Theme" Items="Categories?.Publishers" />
|
||||||
|
|
||||||
|
<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="StorageSpaceDto" Placeholder="@ResourcesKey.StorageSize" GetLabel="@GetStorageSpaceLabel"
|
||||||
|
@bind-Values=GameFilter.StorageSpaces @bind-Values:after=HandleValueChanged Theme="Theme" Items="StorageSpaces" />
|
||||||
|
|
||||||
<span class="title">@ResourcesKey.LastAdd</span>
|
<span class="title">@ResourcesKey.LastAdd</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
using GameIdeas.BlazorApp.Helpers;
|
||||||
|
using GameIdeas.BlazorApp.Pages.Games.Header;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||||
|
using GameIdeas.Resources;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
@@ -11,9 +14,43 @@ public partial class AdvancedGameFilter
|
|||||||
[Parameter] public EventCallback<GameFilterParams> GameFilterChanged { get; set; }
|
[Parameter] public EventCallback<GameFilterParams> GameFilterChanged { get; set; }
|
||||||
|
|
||||||
private readonly SelectTheme Theme = SelectTheme.AdvancedFilter;
|
private readonly SelectTheme Theme = SelectTheme.AdvancedFilter;
|
||||||
|
private readonly List<StorageSpaceDto> StorageSpaces = [
|
||||||
|
new() { MaxSize = 100 },
|
||||||
|
new() { MinSize = 100, MaxSize = 1000 },
|
||||||
|
new() { MinSize = 1000, MaxSize = 5000 },
|
||||||
|
new() { MinSize = 5000, MaxSize = 10000 },
|
||||||
|
new() { MinSize = 10000, MaxSize = 20000 },
|
||||||
|
new() { MinSize = 20000, MaxSize = 40000 },
|
||||||
|
new() { MinSize = 40000, MaxSize = 100000 },
|
||||||
|
new() { MinSize = 100000 },
|
||||||
|
];
|
||||||
|
|
||||||
private async Task HandleValueChanged()
|
private async Task HandleValueChanged()
|
||||||
{
|
{
|
||||||
await GameFilterChanged.InvokeAsync(GameFilter);
|
await GameFilterChanged.InvokeAsync(GameFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetStorageSpaceLabel(StorageSpaceDto storageSpace)
|
||||||
|
{
|
||||||
|
if (storageSpace.MinSize == null && storageSpace.MaxSize != null)
|
||||||
|
{
|
||||||
|
return string.Format(ResourcesKey.MinStorageSpaceFormat,
|
||||||
|
GameHelper.GetFormatedStorageSpace(storageSpace.MinSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (storageSpace.MinSize != null && storageSpace.MaxSize == null)
|
||||||
|
{
|
||||||
|
return string.Format(ResourcesKey.MaxStorageSpaceFormat,
|
||||||
|
GameHelper.GetFormatedStorageSpace(storageSpace.MaxSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (storageSpace.MinSize != null && storageSpace.MaxSize != null)
|
||||||
|
{
|
||||||
|
return string.Format(ResourcesKey.MinMaxStorageSpaceFormat,
|
||||||
|
GameHelper.GetFormatedStorageSpace(storageSpace.MinSize),
|
||||||
|
GameHelper.GetFormatedStorageSpace(storageSpace.MaxSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
|
using GameIdeas.Shared.Dto;
|
||||||
namespace GameIdeas.Shared.Dto;
|
|
||||||
|
namespace GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||||
|
|
||||||
public class GameFilterParams
|
public class GameFilterParams
|
||||||
{
|
{
|
||||||
@@ -14,6 +15,5 @@ public class GameFilterParams
|
|||||||
public int MinInterest { get; set; } = 1;
|
public int MinInterest { get; set; } = 1;
|
||||||
public int MaxInterest { get; set; } = 5;
|
public int MaxInterest { get; set; } = 5;
|
||||||
public List<int>? ReleaseYears { get; set; }
|
public List<int>? ReleaseYears { get; set; }
|
||||||
public int? MinStorageSize { get; set; }
|
public List<StorageSpaceDto>? StorageSpaces { get; set; }
|
||||||
public int? MaxStorageSize { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,5 +40,5 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Popup @ref=ManualAddPopup BackdropFilterClicked="HandleBackdropManualAddClicked" Closable=false>
|
<Popup @ref=ManualAddPopup BackdropFilterClicked="HandleBackdropManualAddClicked" Closable=false>
|
||||||
<GameCreationForm Categories="Categories" OnSubmit="() => HandleFetchDatas(true)" />
|
<GameCreationForm Categories="Categories" OnSubmit="() => HandleFetchDatas()" />
|
||||||
</Popup>
|
</Popup>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||||
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Popup;
|
using GameIdeas.BlazorApp.Shared.Components.Popup;
|
||||||
using GameIdeas.BlazorApp.Shared.Models;
|
using GameIdeas.BlazorApp.Shared.Models;
|
||||||
@@ -28,7 +29,7 @@ public partial class Game
|
|||||||
GameFilter.SortProperty= Filter.GameFilter.GameProperties
|
GameFilter.SortProperty= Filter.GameFilter.GameProperties
|
||||||
.First(gp => gp.PropertyName == nameof(GameIdeas.Shared.Model.Game.Title));
|
.First(gp => gp.PropertyName == nameof(GameIdeas.Shared.Model.Game.Title));
|
||||||
|
|
||||||
await HandleFetchDatas(true);
|
await HandleFetchDatas();
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,11 +50,11 @@ public partial class Game
|
|||||||
{
|
{
|
||||||
ManualAddPopup?.Close();
|
ManualAddPopup?.Close();
|
||||||
}
|
}
|
||||||
private async Task HandleFetchDatas(bool loadCategories = false)
|
private async Task HandleFetchDatas(bool loadCategories = true, bool displayLoader = true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = displayLoader;
|
||||||
|
|
||||||
if (loadCategories)
|
if (loadCategories)
|
||||||
Categories = await GameGateway.FetchCategories();
|
Categories = await GameGateway.FetchCategories();
|
||||||
@@ -72,6 +73,6 @@ public partial class Game
|
|||||||
private async Task HandleFilterChanged(GameFilterParams args)
|
private async Task HandleFilterChanged(GameFilterParams args)
|
||||||
{
|
{
|
||||||
GameFilter = args;
|
GameFilter = args;
|
||||||
await HandleFetchDatas(false);
|
await HandleFetchDatas(loadCategories: false, displayLoader: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using GameIdeas.BlazorApp.Services;
|
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||||
|
using GameIdeas.BlazorApp.Services;
|
||||||
using GameIdeas.BlazorApp.Shared.Constants;
|
using GameIdeas.BlazorApp.Shared.Constants;
|
||||||
using GameIdeas.BlazorApp.Shared.Exceptions;
|
using GameIdeas.BlazorApp.Shared.Exceptions;
|
||||||
using GameIdeas.Resources;
|
using GameIdeas.Resources;
|
||||||
@@ -44,16 +45,13 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
|
|||||||
Title = filterParams.Title,
|
Title = filterParams.Title,
|
||||||
MaxInterest = filterParams.MaxInterest,
|
MaxInterest = filterParams.MaxInterest,
|
||||||
MinInterest = filterParams.MinInterest,
|
MinInterest = filterParams.MinInterest,
|
||||||
MaxStorageSize = filterParams.MaxStorageSize,
|
StorageSpaces = filterParams.StorageSpaces,
|
||||||
MinStorageSize = filterParams.MinStorageSize,
|
|
||||||
ReleaseYears = filterParams.ReleaseYears,
|
|
||||||
DeveloperIds = filterParams.Developers?.Select(d => d.Id ?? 0).ToList(),
|
DeveloperIds = filterParams.Developers?.Select(d => d.Id ?? 0).ToList(),
|
||||||
PublisherIds = filterParams.Publishers?.Select(d => d.Id ?? 0).ToList(),
|
PublisherIds = filterParams.Publishers?.Select(d => d.Id ?? 0).ToList(),
|
||||||
PlatformIds = filterParams.Platforms?.Select(d => d.Id ?? 0).ToList(),
|
PlatformIds = filterParams.Platforms?.Select(d => d.Id ?? 0).ToList(),
|
||||||
PropertyIds = filterParams.Properties?.Select(d => d.Id ?? 0).ToList(),
|
PropertyIds = filterParams.Properties?.Select(d => d.Id ?? 0).ToList(),
|
||||||
|
ReleaseYears = filterParams.ReleaseYears,
|
||||||
TagIds = filterParams.Tags?.Select(d => d.Id ?? 0).ToList(),
|
TagIds = filterParams.Tags?.Select(d => d.Id ?? 0).ToList(),
|
||||||
SortType = filterParams.SortType?.SortType,
|
|
||||||
SortPropertyName = filterParams.SortProperty?.PropertyName
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = await httpClientService.FetchDataAsync<IEnumerable<GameDto>>(Endpoints.Game.Fetch(filter));
|
var result = await httpClientService.FetchDataAsync<IEnumerable<GameDto>>(Endpoints.Game.Fetch(filter));
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||||
|
using GameIdeas.Shared.Dto;
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Pages.Games.Gateways;
|
namespace GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public partial class SearchInput
|
|||||||
Text = string.Empty;
|
Text = string.Empty;
|
||||||
Timer = new()
|
Timer = new()
|
||||||
{
|
{
|
||||||
Interval = 1000,
|
Interval = 500,
|
||||||
AutoReset = false,
|
AutoReset = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ public class Translations (TranslationService translationService)
|
|||||||
public string ErrorFetchGames => translationService.Translate(nameof(ErrorFetchGames));
|
public string ErrorFetchGames => translationService.Translate(nameof(ErrorFetchGames));
|
||||||
public string Ascending => translationService.Translate(nameof(Ascending));
|
public string Ascending => translationService.Translate(nameof(Ascending));
|
||||||
public string Descending => translationService.Translate(nameof(Descending));
|
public string Descending => translationService.Translate(nameof(Descending));
|
||||||
|
public string ErrorStorageSpaceLabel => translationService.Translate(nameof(ErrorStorageSpaceLabel));
|
||||||
|
public string MinStorageSpaceFormat => translationService.Translate(nameof(MinStorageSpaceFormat));
|
||||||
|
public string MaxStorageSpaceFormat => translationService.Translate(nameof(MaxStorageSpaceFormat));
|
||||||
|
public string MinMaxStorageSpaceFormat => translationService.Translate(nameof(MinMaxStorageSpaceFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ResourcesKey
|
public static class ResourcesKey
|
||||||
@@ -96,4 +100,8 @@ public static class ResourcesKey
|
|||||||
public static string ErrorFetchGames => _instance?.ErrorFetchGames ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchGames is not initialized.");
|
public static string ErrorFetchGames => _instance?.ErrorFetchGames ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchGames is not initialized.");
|
||||||
public static string Ascending => _instance?.Ascending ?? throw new InvalidOperationException("ResourcesKey.Ascending is not initialized.");
|
public static string Ascending => _instance?.Ascending ?? throw new InvalidOperationException("ResourcesKey.Ascending is not initialized.");
|
||||||
public static string Descending => _instance?.Descending ?? throw new InvalidOperationException("ResourcesKey.Descending is not initialized.");
|
public static string Descending => _instance?.Descending ?? throw new InvalidOperationException("ResourcesKey.Descending is not initialized.");
|
||||||
|
public static string ErrorStorageSpaceLabel => _instance?.ErrorStorageSpaceLabel ?? throw new InvalidOperationException("ResourcesKey.ErrorStorageSpaceLabel is not initialized.");
|
||||||
|
public static string MinStorageSpaceFormat => _instance?.MinStorageSpaceFormat ?? throw new InvalidOperationException("ResourcesKey.MinStorageSpaceFormat is not initialized.");
|
||||||
|
public static string MaxStorageSpaceFormat => _instance?.MaxStorageSpaceFormat ?? throw new InvalidOperationException("ResourcesKey.MaxStorageSpaceFormat is not initialized.");
|
||||||
|
public static string MinMaxStorageSpaceFormat => _instance?.MinMaxStorageSpaceFormat ?? throw new InvalidOperationException("ResourcesKey.MinMaxStorageSpaceFormat is not initialized.");
|
||||||
}
|
}
|
||||||
@@ -7,4 +7,5 @@ public class CategoriesDto
|
|||||||
public List<TagDto>? Tags { get; set; }
|
public List<TagDto>? Tags { get; set; }
|
||||||
public List<DeveloperDto>? Developers { get; set; }
|
public List<DeveloperDto>? Developers { get; set; }
|
||||||
public List<PublisherDto>? Publishers { get; set; }
|
public List<PublisherDto>? Publishers { get; set; }
|
||||||
|
public List<int>? ReleaseYears { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ public class GameFilterDto
|
|||||||
public List<int>? TagIds { get; set; }
|
public List<int>? TagIds { get; set; }
|
||||||
public List<int>? PublisherIds { get; set; }
|
public List<int>? PublisherIds { get; set; }
|
||||||
public List<int>? DeveloperIds { get; set; }
|
public List<int>? DeveloperIds { get; set; }
|
||||||
public int MinInterest { get; set; } = 1;
|
public int? MinInterest { get; set; }
|
||||||
public int MaxInterest { get; set; } = 5;
|
public int? MaxInterest { get; set; }
|
||||||
public List<int>? ReleaseYears { get; set; }
|
public List<int>? ReleaseYears { get; set; }
|
||||||
public int? MinStorageSize { get; set; }
|
public List<StorageSpaceDto>? StorageSpaces { get; set; }
|
||||||
public int? MaxStorageSize { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/GameIdeas/GameIdeas.Shared/Dto/StorageSpaceDto.cs
Normal file
7
src/GameIdeas/GameIdeas.Shared/Dto/StorageSpaceDto.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace GameIdeas.Shared.Dto;
|
||||||
|
|
||||||
|
public class StorageSpaceDto
|
||||||
|
{
|
||||||
|
public int? MinSize { get; set; }
|
||||||
|
public int? MaxSize { get; set; }
|
||||||
|
}
|
||||||
@@ -39,5 +39,9 @@
|
|||||||
"Unknown": "Inconnu",
|
"Unknown": "Inconnu",
|
||||||
"ErrorFetchGames": "Erreur lors de la récupération des jeux",
|
"ErrorFetchGames": "Erreur lors de la récupération des jeux",
|
||||||
"Ascending": "Ascendant",
|
"Ascending": "Ascendant",
|
||||||
"Descending": "Descendant"
|
"Descending": "Descendant",
|
||||||
|
"ErrorStorageSpaceLabel": "Erreur lors de la génération des label de l'espace de stockage",
|
||||||
|
"MinStorageSpaceFormat": "Jusqu'à {0}",
|
||||||
|
"MaxStorageSpaceFormat": "Plus de {0}",
|
||||||
|
"MinMaxStorageSpaceFormat": "{0} à {1}"
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,9 @@ public class CategoryService(GameIdeasContext context, IMapper mapper) : ICatego
|
|||||||
var tags = await context.Tags.ToListAsync();
|
var tags = await context.Tags.ToListAsync();
|
||||||
var developers = await context.Developers.ToListAsync();
|
var developers = await context.Developers.ToListAsync();
|
||||||
var publishers = await context.Publishers.ToListAsync();
|
var publishers = await context.Publishers.ToListAsync();
|
||||||
|
var releaseYears = await context.Games
|
||||||
|
.Where(game => game.ReleaseDate != null)
|
||||||
|
.Select(game => game.ReleaseDate!.Value.Year).Distinct().ToListAsync();
|
||||||
|
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
@@ -22,7 +25,8 @@ public class CategoryService(GameIdeasContext context, IMapper mapper) : ICatego
|
|||||||
Properties = mapper.Map<List<PropertyDto>>(properties),
|
Properties = mapper.Map<List<PropertyDto>>(properties),
|
||||||
Tags = mapper.Map<List<TagDto>>(tags),
|
Tags = mapper.Map<List<TagDto>>(tags),
|
||||||
Developers = mapper.Map<List<DeveloperDto>>(developers),
|
Developers = mapper.Map<List<DeveloperDto>>(developers),
|
||||||
Publishers = mapper.Map<List<PublisherDto>>(publishers)
|
Publishers = mapper.Map<List<PublisherDto>>(publishers),
|
||||||
|
ReleaseYears = mapper.Map<List<int>>(releaseYears)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using GameIdeas.Shared.Exceptions;
|
|||||||
using GameIdeas.Shared.Model;
|
using GameIdeas.Shared.Model;
|
||||||
using GameIdeas.WebAPI.Context;
|
using GameIdeas.WebAPI.Context;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace GameIdeas.WebAPI.Services.Games;
|
namespace GameIdeas.WebAPI.Services.Games;
|
||||||
@@ -31,7 +32,7 @@ public class GameReadService(GameIdeasContext context, IMapper mapper) : IGameRe
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(filter.Title))
|
if (!string.IsNullOrWhiteSpace(filter.Title))
|
||||||
{
|
{
|
||||||
games = ApplySearchGameFilter(games, filter).ToList();
|
games = [.. ApplySearchGameFilter(games, filter)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapper.Map<IEnumerable<GameDto>>(games);
|
return mapper.Map<IEnumerable<GameDto>>(games);
|
||||||
@@ -81,6 +82,52 @@ public class GameReadService(GameIdeasContext context, IMapper mapper) : IGameRe
|
|||||||
query = query.Where(game => filter.PlatformIds.All(plat =>
|
query = query.Where(game => filter.PlatformIds.All(plat =>
|
||||||
game.GamePlatforms.Any(gp => gp.PlatformId == plat)));
|
game.GamePlatforms.Any(gp => gp.PlatformId == plat)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.PropertyIds != null)
|
||||||
|
{
|
||||||
|
query = query.Where(game => filter.PropertyIds.All(prop =>
|
||||||
|
game.GameProperties.Any(gp => gp.PropertyId == prop)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.TagIds != null)
|
||||||
|
{
|
||||||
|
query = query.Where(game => filter.TagIds.All(tag =>
|
||||||
|
game.GameTags.Any(gt => gt.TagId == tag)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.PublisherIds != null)
|
||||||
|
{
|
||||||
|
query = query.Where(game => filter.PublisherIds.All(pub =>
|
||||||
|
game.GamePublishers.Any(gp => gp.PublisherId == pub)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.DeveloperIds != null)
|
||||||
|
{
|
||||||
|
query = query.Where(game => filter.DeveloperIds.All(dev =>
|
||||||
|
game.GameDevelopers.Any(gd => gd.DeveloperId == dev)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.MinInterest != null)
|
||||||
|
{
|
||||||
|
query = query.Where(game => game.Interest >= filter.MinInterest);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.MaxInterest != null)
|
||||||
|
{
|
||||||
|
query = query.Where(game => game.Interest <= filter.MaxInterest);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.StorageSpaces != null)
|
||||||
|
{
|
||||||
|
query = query.Where(game => filter.StorageSpaces.Where(stor =>
|
||||||
|
stor.MinSize <= game.StorageSpace && stor.MaxSize > game.StorageSpace).Count() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.ReleaseYears != null)
|
||||||
|
{
|
||||||
|
query = query.Where(game => game.ReleaseDate != null &&
|
||||||
|
filter.ReleaseYears.Contains(game.ReleaseDate.Value.Year));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<Game> ApplySearchGameFilter(IEnumerable<Game> query, GameFilterDto filter)
|
private static IEnumerable<Game> ApplySearchGameFilter(IEnumerable<Game> query, GameFilterDto filter)
|
||||||
|
|||||||
Reference in New Issue
Block a user