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.
47 lines
1.5 KiB
47 lines
1.5 KiB
using API.Dto;
|
|
using Model;
|
|
using System.Collections.ObjectModel;
|
|
using System.Reflection.PortableExecutable;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
using System.Security.Claims;
|
|
|
|
namespace API.Mapping
|
|
{
|
|
public static class ChampionMapper
|
|
{
|
|
public static ChampionDto ToDto(this Champion champion)
|
|
{
|
|
if (champion == null)
|
|
{
|
|
throw new ArgumentNullException("Champion null");
|
|
}
|
|
|
|
return new ChampionDto
|
|
{
|
|
Name = champion.Name,
|
|
Bio = champion.Bio,
|
|
Icon = champion.Icon,
|
|
|
|
NameCharac = champion.Characteristics.Keys,
|
|
ValueCharac = champion.Characteristics.Values,
|
|
|
|
Class = champion.Class,
|
|
Skins = champion.Skins,
|
|
Skills = champion.Skills,
|
|
Image = champion.Image
|
|
};
|
|
}
|
|
public static Champion ToModel(this ChampionDto DtoChamp)
|
|
{
|
|
if (DtoChamp == null)
|
|
{
|
|
throw new ArgumentNullException("DtoChampion null");
|
|
}
|
|
var champion = new Champion(DtoChamp.Name, DtoChamp.Class, DtoChamp.Icon, DtoChamp.Image.Base64, DtoChamp.Bio);
|
|
if (DtoChamp.Skills != null) foreach (var skill in DtoChamp.Skills) { champion.AddSkill(skill.toModel()); }
|
|
if (DtoChamp.Characteristics != null) foreach (var charac in DtoChamp.Characteristics) { champion.AddCharacteristics(charac.toModel()); }
|
|
return champion;
|
|
}
|
|
}
|
|
}
|