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.
49 lines
1.5 KiB
49 lines
1.5 KiB
using DbManager.Mapper.enums;
|
|
using Model;
|
|
using MyFlib;
|
|
using MyFlib.Entities;
|
|
|
|
namespace DbManager.Mapper
|
|
{
|
|
public static class RunePageMapper
|
|
{
|
|
public static RunePage ToModel(this RunePageEntity runePageEntity, LolDbContext context)
|
|
{
|
|
RunePage runePage = new(runePageEntity.Name);
|
|
foreach (var d in runePageEntity.DictionaryCategoryRunes)
|
|
{
|
|
var rune = context.Runes.Find(d.RuneName);
|
|
if (rune!=null)
|
|
{
|
|
runePage[d.category.ToModel()] = rune.ToModel();
|
|
}
|
|
}
|
|
return runePage;
|
|
}
|
|
|
|
public static RunePageEntity ToEntity(this RunePage runePage, LolDbContext context)
|
|
{
|
|
RunePageEntity? runePageEntity = context.RunePages.Find(runePage.Name);
|
|
if (runePageEntity == null)
|
|
{
|
|
runePageEntity = new()
|
|
{
|
|
Name = runePage.Name,
|
|
};
|
|
|
|
runePageEntity.DictionaryCategoryRunes = new List<DictionaryCategoryRune>();
|
|
foreach (var r in runePage.Runes)
|
|
{
|
|
runePageEntity.DictionaryCategoryRunes.Add(new DictionaryCategoryRune()
|
|
{
|
|
category = r.Key.ToEntity(),
|
|
rune = r.Value.ToEntity(),
|
|
});
|
|
}
|
|
|
|
}
|
|
return runePageEntity;
|
|
}
|
|
}
|
|
}
|