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.
League-of-Legends_Project/EntityFramework_LoL/Sources/EntityMappers/SkillMapper.cs

34 lines
950 B

using Entities;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityMappers
{
public static class SkillMapper
{
public static SkillEntity ToEntity(this Skill item, ChampionEntity champion, LolDbContext context)
{
var skillEntity = context.skills.Find(item.Name);
if (skillEntity == null) {
return new()
{
Name = item.Name,
Description = item.Description,
SkillType = item.Type,
Champions = new List<ChampionEntity>() { champion }
};
}
skillEntity!.Champions?.Add(champion);
return skillEntity;
}
public static Skill ToModel(this SkillEntity entity)
=> new(entity.Name, entity.SkillType,entity.Description);
}
}