using AutoMapper; using GameIdeas.Shared.Dto; using GameIdeas.Shared.Enum; using GameIdeas.Shared.Model; using GameIdeas.WebAPI.Context; using Microsoft.EntityFrameworkCore; namespace GameIdeas.WebAPI.Services; public class GameService(GameIdeasContext context, IMapper mapper) { public async Task> SearchGames(GameFilterDto filter) { var query = context.Games .Include(g => g.CreationUser) .Include(g => g.ModificationUser) .Include(g => g.GamePlatforms).ThenInclude(p => p.Platform) .Include(g => g.GameProperties).ThenInclude(p => p.Property) .Include(g => g.GameTags).ThenInclude(p => p.Tag) .Include(g => g.GamePublishers).ThenInclude(p => p.Publisher) .Include(g => g.GameDevelopers).ThenInclude(p => p.Developer) .AsQueryable(); ApplyFilter(ref query); var games = await query .OrderBy(g => g.Title) .Skip(filter.CurrentPage * filter.NumberPerPage) .Take(filter.NumberPerPage) .ToListAsync(); List gamesTest = [ new () { Id = 1, Title = "Test", CreationDate = DateTime.Today - TimeSpan.FromHours(-12), CreationUser = new User() { Id = 1, Username = "Test", Role = (int)Role.Administrator }, CreationUserId = 1, Description = "Test", GameDevelopers = [ new() { Developer = new Developer() { Id = 1, Name = "THQNordic"} }], GamePlatforms = [ new() { Platform = new Platform() { Id = 1, Label = "Steam" }, Url = "steam.com?app=55554131" }], GameProperties = [ new () { Property = new Property() { Id = 1, Label = "Coop"} }], GamePublishers = [ new () { Publisher = new Publisher() { Id = 1, Name = "Take-Two"} }], GameTags = [ new () { Tag = new Tag() { Id = 1, Label = "RPG" } }], Interest = 5, ModificationDate = DateTime.Today , ModificationUser = new User() { Id = 2, Username = "Test 2", Role = (int)Role.Member }, ModificationUserId = 2, ReleaseDate = new DateTime(2025, 2, 1), StorageSpace = 40 } ]; return mapper.Map>(gamesTest); } private void ApplyFilter(ref IQueryable query) { } }