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();
    }
}
