From a91154ff3a0c9bdcad1b947e7cc25b252adf5f6a Mon Sep 17 00:00:00 2001 From: "arthur.valin" Date: Sat, 25 Mar 2023 11:52:52 +0100 Subject: [PATCH] Adding large image to entity mappers --- EntityFramework_LoL/Sources/Entities/ChampionEntity.cs | 3 ++- EntityFramework_LoL/Sources/Entities/RuneEntity.cs | 2 ++ .../Sources/EntityMappers/ChampionMapper.cs | 3 ++- EntityFramework_LoL/Sources/EntityMappers/RuneMapper.cs | 7 +++++-- EntityFramework_LoL/Sources/EntityMappers/SkinMapper.cs | 7 +++++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs b/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs index 42c060c..4480243 100644 --- a/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs +++ b/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs @@ -13,7 +13,8 @@ namespace Entities [Required] [MaxLength(500)] public string Bio { get; set; } - public string? Icon { get; set; } + public string Icon { get; set; } + [Required] public ChampionClass Class { get; set;} public virtual ICollection Skills { get; set; } diff --git a/EntityFramework_LoL/Sources/Entities/RuneEntity.cs b/EntityFramework_LoL/Sources/Entities/RuneEntity.cs index a456235..9abbe02 100644 --- a/EntityFramework_LoL/Sources/Entities/RuneEntity.cs +++ b/EntityFramework_LoL/Sources/Entities/RuneEntity.cs @@ -19,6 +19,8 @@ namespace Entities [MaxLength(500)] public string Description { get; set; } + public string Icon { get; set; } + [Required] public RuneFamily RuneFamily { get; set; } public ICollection? runepages { get; set; } diff --git a/EntityFramework_LoL/Sources/EntityMappers/ChampionMapper.cs b/EntityFramework_LoL/Sources/EntityMappers/ChampionMapper.cs index e00b0e3..43a754a 100644 --- a/EntityFramework_LoL/Sources/EntityMappers/ChampionMapper.cs +++ b/EntityFramework_LoL/Sources/EntityMappers/ChampionMapper.cs @@ -30,7 +30,8 @@ namespace EntityMapper public static Champion ToModel(this ChampionEntity entity) { - var champion = new Champion(entity.Name, entity.Class, entity.Icon, "", entity.Bio); + var image = entity?.Image?.Base64 ?? ""; + var champion = new Champion(entity?.Name ?? "", entity?.Class??Shared.ChampionClass.Unknown, entity?.Icon??"", image , entity?.Bio??""); if(entity.Skills!=null) foreach(var s in entity.Skills){champion.AddSkill(s.ToModel());} if (entity.Characteristics != null) foreach (var c in entity.Characteristics){champion.AddCharacteristics(c.ToModel()); } return champion; diff --git a/EntityFramework_LoL/Sources/EntityMappers/RuneMapper.cs b/EntityFramework_LoL/Sources/EntityMappers/RuneMapper.cs index 5dcf3d8..4cac4f4 100644 --- a/EntityFramework_LoL/Sources/EntityMappers/RuneMapper.cs +++ b/EntityFramework_LoL/Sources/EntityMappers/RuneMapper.cs @@ -14,7 +14,9 @@ namespace EntityMapper { Name = item.Name, Description = item.Description, - RuneFamily = item.Family + RuneFamily = item.Family, + Icon = item.Icon, + Image = new() { Base64 = item.Image.Base64 }, }; } return runeEntity; @@ -23,7 +25,8 @@ namespace EntityMapper public static Rune ToModel(this RuneEntity entity) { - return new Rune(entity.Name, entity.RuneFamily, "", "", entity.Description); + var image = entity?.Image?.Base64 ?? ""; + return new Rune(entity?.Name ?? "", entity?.RuneFamily??Shared.RuneFamily.Unknown, entity?.Icon ?? "", image, entity?.Description??""); } } diff --git a/EntityFramework_LoL/Sources/EntityMappers/SkinMapper.cs b/EntityFramework_LoL/Sources/EntityMappers/SkinMapper.cs index c595ec2..4a172b7 100644 --- a/EntityFramework_LoL/Sources/EntityMappers/SkinMapper.cs +++ b/EntityFramework_LoL/Sources/EntityMappers/SkinMapper.cs @@ -15,14 +15,17 @@ namespace EntityMapper ChampionForeignKey = item.Champion.Name, Description = item.Description, Icon = item.Icon, - Image = null, + Image = new() { Base64 = item.Image.Base64 }, Price = item.Price }; } public static Skin ToModel(this SkinEntity entity) - => new(entity.Name, entity.Champion.ToModel(), entity.Price, null, entity.Description); + { + var image = entity?.Image?.Base64 ?? ""; + return new(entity?.Name ?? "", entity?.Champion?.ToModel()??new(""), entity?.Price??-1, image, entity?.Description??""); + } } }