diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs index ae1ada6..52d7185 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs @@ -28,7 +28,7 @@ namespace ApiLol.Controllers if (pageRequest.count + pageRequest.index > nbTotal) { _logger.LogWarning($"too many, maximum {nbTotal}"); - pageRequest.count = 10; + return BadRequest("Champion limit exceed"); } _logger.LogInformation($"method Get call"); diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs index dbb9679..fed7f20 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs @@ -13,13 +13,14 @@ namespace ApiLol.Mapper Bio = champion.Bio, Class = champion.Class.ToDto(), Icon = champion.Icon, - Image = champion.Image.Base64 + Image = champion.Image.ToDto(), + Skins = champion.Skins.Select(e => e.ToDto()) }; } public static Champion ToModel(this ChampionDto championDto) { - return new Champion(championDto.Name, championDto.Class.ToModel(), championDto.Icon, championDto.Image,championDto.Bio); + return new Champion(championDto.Name, championDto.Class.ToModel(), championDto.Icon, championDto.Image.Base64,championDto.Bio); } } diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs new file mode 100644 index 0000000..6bebb6f --- /dev/null +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs @@ -0,0 +1,21 @@ +using DTO; +using Model; + +namespace ApiLol.Mapper +{ + public static class LargeImageMapper + { + public static LargeImageDto ToDto(this LargeImage largeImage) + { + return new LargeImageDto() + { + Base64 = largeImage.Base64 + }; + } + + public static LargeImage ToModel(this LargeImageDto largeImageDto) + { + return new LargeImage(largeImageDto.Base64); + } + } +} \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs index fcd88a6..276d0ac 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs @@ -14,7 +14,7 @@ namespace ApiLol.Mapper }; } -/* public static Rune ToModel(this RuneDto rune) +/* public static Rune ToModel(this RuneDto runeDto) { return new Rune(rune.Name) { diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs index 768caf7..97bec89 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs @@ -14,7 +14,7 @@ namespace ApiLol.Mapper }; } -/* public static Skill ToModel(this SkillDto skill) +/* public static Skill ToModel(this SkillDto skillDto) { return new Skill(skill.Name) { diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs index a093e12..9925eac 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs @@ -1,18 +1,25 @@ using DTO; +using Model; namespace ApiLol.Mapper { public static class SkinMapper { - public static SkinDto ToDto(this SkinDto skin) + public static SkinDto ToDto(this Skin skin) { return new SkinDto() { Name = skin.Name, Description = skin.Description, Icon = skin.Icon, + Image = skin.Image.ToDto(), Price = skin.Price }; } + + public static Skin ToModel(this SkinDto skinDto) + { + return new Skin(skinDto.Name, null, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description); + } } -} +} \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/ChampionClassMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/ChampionClassMapper.cs index c0c52ed..a96d7bf 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/ChampionClassMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/ChampionClassMapper.cs @@ -9,9 +9,9 @@ namespace ApiLol.Mapper { return (ChampionClassDto) championClass; } - public static ChampionClass ToModel(this ChampionClassDto championClass) + public static ChampionClass ToModel(this ChampionClassDto championClassDto) { - return (ChampionClass) championClass; + return (ChampionClass) championClassDto; } } } diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/SkillTypeMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/SkillTypeMapper.cs new file mode 100644 index 0000000..05689c1 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/SkillTypeMapper.cs @@ -0,0 +1,58 @@ +using DTO; +using DTO.enums; +using Model; + +namespace ApiLol.Mapper.enums +{ + public static class SkillTypeMapper + { + public static SkillTypeDto ToDto(this SkillType skillType) + { + if (skillType == SkillType.Unknown) + { + return SkillTypeDto.Unknown; + } + if (skillType == SkillType.Basic) + { + return SkillTypeDto.Basic; + } + if (skillType == SkillType.Passive) + { + return SkillTypeDto.Passive; + } + if (skillType == SkillType.Ultimate) + { + return SkillTypeDto.Ultimate; + } + else + { + return SkillTypeDto.Unknown; + } + + } + public static SkillType ToModel(this SkillTypeDto skillTypeDto) + { + if (skillTypeDto == SkillTypeDto.Unknown) + { + return SkillType.Unknown; + } + if (skillTypeDto == SkillTypeDto.Basic) + { + return SkillType.Basic; + } + if (skillTypeDto == SkillTypeDto.Passive) + { + return SkillType.Passive; + } + if (skillTypeDto == SkillTypeDto.Ultimate) + { + return SkillType.Ultimate; + } + else + { + return SkillType.Unknown; + } + + } + } +} \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/Client/Program.cs b/src/EntityFramework_LoL/Sources/Client/Program.cs index 3751555..bfb6ef0 100644 --- a/src/EntityFramework_LoL/Sources/Client/Program.cs +++ b/src/EntityFramework_LoL/Sources/Client/Program.cs @@ -1,2 +1,2 @@ // See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +Console.WriteLine("Hello, World!"); \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/DTO/ChampionDto.cs b/src/EntityFramework_LoL/Sources/DTO/ChampionDto.cs index 09f009b..d09bd80 100644 --- a/src/EntityFramework_LoL/Sources/DTO/ChampionDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/ChampionDto.cs @@ -6,7 +6,7 @@ public string Bio { get; set; } public ChampionClassDto Class { get; set; } public string Icon { get; set; } - public string Image { get; set; } + public LargeImageDto Image { get; set; } public IEnumerable Skins { get; set; } } diff --git a/src/EntityFramework_LoL/Sources/DTO/LargeImageDto.cs b/src/EntityFramework_LoL/Sources/DTO/LargeImageDto.cs new file mode 100644 index 0000000..133ac67 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DTO/LargeImageDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DTO +{ + public class LargeImageDto + { + public string Base64 { get; set; } + } +} diff --git a/src/EntityFramework_LoL/Sources/DTO/SkinDto.cs b/src/EntityFramework_LoL/Sources/DTO/SkinDto.cs index 2c3962b..8ff7cca 100644 --- a/src/EntityFramework_LoL/Sources/DTO/SkinDto.cs +++ b/src/EntityFramework_LoL/Sources/DTO/SkinDto.cs @@ -11,6 +11,7 @@ namespace DTO public string Name { get; set; } public string Description { get; set; } public string Icon { get; set; } + public LargeImageDto Image { get; set; } public float Price { get; set; } } diff --git a/src/EntityFramework_LoL/Sources/DTO/enums/SkillTypeDto.cs b/src/EntityFramework_LoL/Sources/DTO/enums/SkillTypeDto.cs new file mode 100644 index 0000000..656b59f --- /dev/null +++ b/src/EntityFramework_LoL/Sources/DTO/enums/SkillTypeDto.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DTO.enums +{ + public enum SkillTypeDto + { + Unknown, + Basic, + Passive, + Ultimate + } +} diff --git a/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs index 590e9e1..20a0398 100644 --- a/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs +++ b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs @@ -26,7 +26,7 @@ namespace ApiTests //Act var total = await stub.ChampionsMgr.GetNbItems(); - var champion = await champs.Get(new PageRequest()); + var champion = await champs.Get(new PageRequest() { index = 0, count = total }); //Assert var objectResult = champion as OkObjectResult;