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.
71 lines
2.0 KiB
71 lines
2.0 KiB
using DbConnectionLibrairie;
|
|
using Entities;
|
|
using EntityManagers;
|
|
using ExtensionsClassLibrairie;
|
|
using ManagerInterfaces;
|
|
using Model;
|
|
using OrderCriterias;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DataManagers
|
|
{
|
|
public class LobbyDataManager : ILobbyManager<Lobby>
|
|
{
|
|
private ILobbyManager<LobbyEntity> manager;
|
|
|
|
public LobbyDataManager(ILobbyManager<LobbyEntity> manager)
|
|
{
|
|
this.manager = manager;
|
|
}
|
|
|
|
public async Task<Lobby> addLobby(Lobby lobby)
|
|
{
|
|
return await Task.FromResult<Lobby>((await manager.addLobby(lobby.ToEntity())).ToModel());
|
|
}
|
|
|
|
public async Task<(int nbPages, IEnumerable<Lobby>? lobbies)> getLobbies(int nb, int count, LobbyOrderCriteria orderCriteria = LobbyOrderCriteria.ById)
|
|
{
|
|
List<Lobby>? tmp = new List<Lobby>();
|
|
var res = await manager.getLobbies(nb, count, orderCriteria);
|
|
if (res.lobbies == null) tmp = null;
|
|
else
|
|
{
|
|
foreach (var item in res.lobbies)
|
|
{
|
|
tmp.Add(item.ToModel());
|
|
}
|
|
}
|
|
return await Task.FromResult<(int nbPages, IEnumerable<Lobby>? lobbies)>((res.nbPages, tmp));
|
|
}
|
|
|
|
public async Task<Lobby?> getLobby(int id)
|
|
{
|
|
return await Task.FromResult<Lobby?>((await manager.getLobby(id))?.ToModel());
|
|
}
|
|
|
|
public async Task<Lobby?> getLobby(string name, int? idCreator)
|
|
{
|
|
return (await manager.getLobby(name, idCreator))?.ToModel();
|
|
}
|
|
|
|
public int getNbLobbies()
|
|
{
|
|
return manager.getNbLobbies();
|
|
}
|
|
|
|
public async Task<Lobby?> removeLobby(Lobby lobby)
|
|
{
|
|
return (await manager.removeLobby(lobby.ToEntity()))?.ToModel();
|
|
}
|
|
|
|
public async Task<Lobby?> removeLobby(int id)
|
|
{
|
|
return (await manager.removeLobby(id))?.ToModel();
|
|
}
|
|
}
|
|
}
|