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.
LOLProject/Sources/APILOL/Mapper/ChampionMapper.cs

44 lines
1.3 KiB

using DTO;
using EntityFrameworkLOL.Entities;
using Model;
namespace APILOL.Mapper
{
public static class ChampionMapper
{
public static ChampionDTO ToDto(this Champion champion)
{
return new ChampionDTO()
{
Name = champion.Name,
Bio = champion.Bio,
Class = champion.Class,
Icon = champion.Icon,
Image = champion.Image,
Skills = champion.Skills.Select(skill => skill.ToDto()),
};
}
public static Champion ToModel(this ChampionDTO champion)
{
return new Champion(champion.Name, champion.Class, champion.Icon, champion.Image.ToString(), champion.Bio);
}
public static ChampionEntity ToEntity(this Champion item)
{
return new()
{
Name = item.Name,
Bio = item.Bio,
Icon = item.Icon,
Class = item.Class,
Image = new() { Base64 = item.Image.Base64 },
};
}
public static Champion ToModel(this ChampionEntity entity)
{
return new(entity.Name, entity.Class, entity.Icon, entity.Image.Base64, entity.Bio);
}
}
}