Add services and controllers for games #12

Merged
Egamorf merged 7 commits from release/add-services-controllers into main 2025-04-12 21:34:45 +02:00
Showing only changes of commit 5d655d8b4b - Show all commits

View File

@@ -1,9 +1,11 @@
using AutoMapper;
using GameIdeas.Shared.Dto;
using GameIdeas.Shared.Enum;
using GameIdeas.Shared.Exceptions;
using GameIdeas.Shared.Model;
using GameIdeas.WebAPI.Context;
using Microsoft.EntityFrameworkCore;
using System.Data.SqlTypes;
namespace GameIdeas.WebAPI.Services;
@@ -27,7 +29,26 @@ public class GameService(GameIdeasContext context, IMapper mapper)
.Take(pagging.NumberPerPage)
.ToListAsync();
return mapper.Map<IEnumerable<GameDto>>(games);
List<Game> gameTest = [ 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<IEnumerable<GameDto>>(gameTest);
}
public async Task<GameDto> GetGameById(int gameId)