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.

62 lines
2.1 KiB

using EFlib;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EFManager
{
public static class ManagerTranslate
{
// Champion
public static EFChampion toEF(this Champion Champ, SQLiteContext context)
{
EFChampion? EfChampion = context.Champions.Find(Champ.Name);
if (EfChampion == null)
{
EfChampion = new()
{
Name = Champ.Name,
Bio = Champ.Bio,
Icon = Champ.Icon,
Class = Champ.Class,
Image = new() { Id = Guid.NewGuid(), Base64 = Champ.Image.Base64 },
};
EfChampion.Skills = Champ.Skills.Select(Skill => Skill.toEF(EfChampion, context)).ToList();
EfChampion.Characteristics = Champ.Characteristics.Select(Charac => Charac.toEF(EfChampion, context)).ToList();
}
return EfChampion;
}
public static Champion toModel(this EFChampion EFChamp)
{
var champion = new Champion(EFChamp.Name, EFChamp.Class, EFChamp.Icon, "", EFChamp.Bio);
if (EFChamp.Skills != null) foreach (var s in EFChamp.Skills) { champion.AddSkill(s.toModel()); }
if (EFChamp.Characteristics != null) foreach (var c in EFChamp.Characteristics) { champion.AddCharacteristics(c.toModel()); }
return champion;
}
// Characteristics
// Skin
public static EFSkin toEF(this Skin Skin) => new EFSkin { Name = Skin.Name, Description = Skin.Description, Icon = Skin.Icon, Price = Skin.Price };
public static Skin toModel(this EFSkin EFSkin) => new Skin(EFSkin.Name, EFSkin.Champion.toModel());
// Skill
// LargeImage
public static EFLargeImage toEF(this LargeImage LargeImage) => new EFLargeImage { Id = Guid.NewGuid(), Base64 = LargeImage.Base64 };
public static LargeImage toModel(this EFLargeImage EFlargeImage) => new LargeImage(EFlargeImage.Base64);
// Rune
// RunePage
}
}