You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
66 lines
2.0 KiB
using DbConnectionLibrairie;
|
|
using DataManagers;
|
|
using ExtensionsClassLibrairie;
|
|
using ManagerInterfaces;
|
|
using Model;
|
|
using OrderCriterias;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using DTOs;
|
|
|
|
namespace ServiceManagers
|
|
{
|
|
public class LobbyServiceManager(ILobbyManager<Lobby> manager) : ILobbyManager<LobbyDto>
|
|
{
|
|
private ILobbyManager<Lobby> manager = manager;
|
|
|
|
public async Task<LobbyDto> addLobby(LobbyDto lobbydto)
|
|
{
|
|
return await Task.FromResult<LobbyDto>((await manager.addLobby(lobbydto.ToModel())).ToDto());
|
|
}
|
|
|
|
public async Task<(int nbPages, IEnumerable<LobbyDto>? lobbies)> getLobbies(int nb, int count, LobbyOrderCriteria orderCriteria = LobbyOrderCriteria.ById)
|
|
{
|
|
List<LobbyDto>? tmp = new List<LobbyDto>();
|
|
var res = await manager.getLobbies(nb, count, orderCriteria);
|
|
if (res.lobbies == null) tmp = null;
|
|
else
|
|
{
|
|
foreach (var item in res.lobbies)
|
|
{
|
|
tmp.Add(item.ToDto());
|
|
}
|
|
}
|
|
return await Task.FromResult<(int nbPages, IEnumerable<LobbyDto>? lobbies)>((res.nbPages, tmp));
|
|
}
|
|
|
|
public async Task<LobbyDto?> getLobby(int id)
|
|
{
|
|
return (await manager.getLobby(id))?.ToDto();
|
|
}
|
|
|
|
public async Task<LobbyDto?> getLobby(string name, int? idCreator)
|
|
{
|
|
return (await manager.getLobby(name, idCreator))?.ToDto();
|
|
}
|
|
|
|
public int getNbLobbies()
|
|
{
|
|
return manager.getNbLobbies();
|
|
}
|
|
|
|
public async Task<LobbyDto?> removeLobby(LobbyDto lobbydto)
|
|
{
|
|
return (await manager.removeLobby(lobbydto.ToModel()))?.ToDto();
|
|
}
|
|
|
|
public async Task<LobbyDto?> removeLobby(int id)
|
|
{
|
|
return (await manager.removeLobby(id))?.ToDto();
|
|
}
|
|
}
|
|
}
|