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.
49 lines
1.5 KiB
49 lines
1.5 KiB
using DTOs;
|
|
using Entities;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ExtensionsClassLibrairie
|
|
{/// <summary>
|
|
/// define some methods to manipulate entity, model and dto lobbies :
|
|
/// convert model to DTO, model to Entity, ...
|
|
/// and equality protocols
|
|
/// </summary>
|
|
public static class LobbyExtensionMethods
|
|
{
|
|
// conversion methods
|
|
public static Lobby ToModel(this LobbyEntity l)
|
|
=> new Lobby(l.Name, l.IdCreator, l.Password, l.NbPlayers, l.Id);
|
|
public static Lobby ToModel(this LobbyDto l)
|
|
=> new Lobby(l.Name, l.IdCreator, l.Password, l.NbPlayers, l.Id);
|
|
public static LobbyDto ToDto(this Lobby l)
|
|
=> new LobbyDto
|
|
{
|
|
Id = l.Id,
|
|
IdCreator = l.IdCreator,
|
|
Name = l.Name,
|
|
Password = l.Password,
|
|
NbPlayers = l.NbPlayers
|
|
};
|
|
public static LobbyEntity ToEntity(this Lobby l)
|
|
=> new LobbyEntity
|
|
{
|
|
Id = l.Id,
|
|
IdCreator = l.IdCreator,
|
|
Name = l.Name,
|
|
Password = l.Password,
|
|
NbPlayers = l.NbPlayers
|
|
};
|
|
|
|
// reuse other methods
|
|
public static LobbyDto ToDto(this LobbyEntity l)
|
|
=> l.ToModel().ToDto();
|
|
public static LobbyEntity ToEntity(this LobbyDto l)
|
|
=> l.ToModel().ToEntity();
|
|
}
|
|
}
|