Add frontend creation game (#13)
Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using AutoMapper;
|
||||
using GameIdeas.Shared.Dto;
|
||||
using GameIdeas.WebAPI.Context;
|
||||
using GameIdeas.WebAPI.Services.Interfaces;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GameIdeas.WebAPI.Services;
|
||||
|
||||
public class CategoryService(GameIdeasContext context, IMapper mapper) : ICategoryService
|
||||
{
|
||||
public async Task<CategoriesDto> GetCategories()
|
||||
{
|
||||
var platforms = await context.Platforms.ToListAsync();
|
||||
var properties = await context.Properties.ToListAsync();
|
||||
var tags = await context.Tags.ToListAsync();
|
||||
var developers = await context.Developers.ToListAsync();
|
||||
var publishers = await context.Publishers.ToListAsync();
|
||||
|
||||
return new()
|
||||
{
|
||||
Platforms = mapper.Map<IEnumerable<PlatformDto>>(platforms),
|
||||
Properties = mapper.Map<IEnumerable<PropertyDto>>(properties),
|
||||
Tags = mapper.Map<IEnumerable<TagDto>>(tags),
|
||||
Developers = mapper.Map<IEnumerable<DeveloperDto>>(developers),
|
||||
Publishers = mapper.Map<IEnumerable<PublisherDto>>(publishers)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,12 @@ using GameIdeas.Shared.Dto;
|
||||
using GameIdeas.Shared.Exceptions;
|
||||
using GameIdeas.Shared.Model;
|
||||
using GameIdeas.WebAPI.Context;
|
||||
using GameIdeas.WebAPI.Services.Interfaces;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GameIdeas.WebAPI.Services;
|
||||
|
||||
public class GameService(GameIdeasContext context, IMapper mapper)
|
||||
public class GameService(GameIdeasContext context, IMapper mapper) : IGameService
|
||||
{
|
||||
public async Task<IEnumerable<GameDto>> GetGames(PaggingDto pagging)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using GameIdeas.Shared.Dto;
|
||||
|
||||
namespace GameIdeas.WebAPI.Services.Interfaces;
|
||||
|
||||
public interface ICategoryService
|
||||
{
|
||||
Task<CategoriesDto> GetCategories();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using GameIdeas.Shared.Dto;
|
||||
|
||||
namespace GameIdeas.WebAPI.Services.Interfaces;
|
||||
|
||||
public interface IGameService
|
||||
{
|
||||
Task<IEnumerable<GameDto>> GetGames(PaggingDto pagging);
|
||||
Task<GameDto> GetGameById(int gameId);
|
||||
Task<GameDto> CreateGame(GameDto gameDto);
|
||||
Task<GameDto> UpdateGame(GameDto gameDto);
|
||||
Task<bool> DeleteGame(int gameId);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
namespace GameIdeas.WebAPI.Services;
|
||||
|
||||
public class UserService
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user