API Dto & Mapping finit
continuous-integration/drone/push Build is failing Details

master
Louis DUFOUR 2 years ago
parent 00f4536d2c
commit f9284d7b79

@ -18,7 +18,7 @@ namespace API.Dto
public ChampionClass Class { get; set; } public ChampionClass Class { get; set; }
public ReadOnlyCollection<SkinDto> Skins { get; set; } public ReadOnlyCollection<SkinDto> Skins { get; set; }
public ImmutableHashSet<SkillDto> Skills { get; private set; } public ImmutableHashSet<SkillDto> Skills { get; set; }
public LargeImage Image { get; set; } public LargeImage Image { get; set; }
} }

@ -1,9 +1,7 @@
using API.Dto; using API.Dto;
using Model; using Model;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Reflection.PortableExecutable; using System.Collections.Immutable;
using static System.Net.Mime.MediaTypeNames;
using System.Security.Claims;
namespace API.Mapping namespace API.Mapping
{ {
@ -26,8 +24,8 @@ namespace API.Mapping
ValueCharac = champion.Characteristics.Values, ValueCharac = champion.Characteristics.Values,
Class = champion.Class, Class = champion.Class,
Skins = champion.Skins, Skins = (ReadOnlyCollection<SkinDto>)champion.Skins.Select(skin => skin.ToDto()),
Skills = champion.Skills, Skills = (ImmutableHashSet<SkillDto>)champion.Skills.Select(skill => skill.ToDto()),
Image = champion.Image Image = champion.Image
}; };
} }
@ -38,8 +36,11 @@ namespace API.Mapping
throw new ArgumentNullException("DtoChampion null"); throw new ArgumentNullException("DtoChampion null");
} }
var champion = new Champion(DtoChamp.Name, DtoChamp.Class, DtoChamp.Icon, DtoChamp.Image.Base64, DtoChamp.Bio); 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.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()); }
champion.AddCharacteristics((Tuple<string, int>)DtoChamp.NameCharac.Zip(DtoChamp.ValueCharac, (name, value) => Tuple.Create(name, value)));
return champion; return champion;
} }
} }

Loading…
Cancel
Save