using DTOs; using Entities; using Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ExtensionsClassLibrairie { /// /// define some methods to manipulate entity, model and dto players : /// convert model to DTO, model to Entity, ... /// and equality protocols /// public static class PlayerExtensionMethods { // conversion methods public static Player ToModel(this PlayerEntity p) => new Player(p.Nickname, p.HashedPassword, p.Id); public static Player ToModel(this PlayerDto p) => new Player(p.Nickname, p.HashedPassword, p.Id); public static PlayerDto ToDto(this Player p) => new PlayerDto { Id = p.Id, Nickname = p.Nickname, HashedPassword = p.HashedPassword}; public static PlayerEntity ToEntity(this Player p) => new PlayerEntity { Id = p.Id, Nickname = p.Nickname, HashedPassword = p.HashedPassword }; // reuse other methods public static PlayerDto ToDto(this PlayerEntity p) => p.ToModel().ToDto(); public static PlayerEntity ToEntity(this PlayerDto p) => p.ToModel().ToEntity(); } }