diff --git a/.vs/LolProject2/v17/.wsuo b/.vs/LolProject2/v17/.wsuo index a3c6a23..cc1d1dc 100644 Binary files a/.vs/LolProject2/v17/.wsuo and b/.vs/LolProject2/v17/.wsuo differ diff --git a/README.md b/README.md index 834d15c..d17dae1 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,14 @@ réalisez à nouveau la migration (ou mettez à jour celle actuelle), puis suppr Si vous préférez éviter la manipulation de l'API, vous pouvez également utiliser le **client MAUI**. Celui-ci contacte directement l'ApiManager, qui se charge des requêtes HTTP à l'API, et vous permet de visualiser et de modifier les données grâce à une interface graphique. +Pour accomplir cela, veuillez configurer les propriétés de la solution en cliquant avec le bouton droit de la souris sur la solution, puis en sélectionnant "propriétés". De cette façon, vous pourrez lancer à la fois l'API et l'application League of Legends. Assurez-vous d'avoir les mêmes configurations : + +
+ +![HowToLaunch](doc/Images/HowToLaunch.png) + +
+ Page **Home**:
diff --git a/doc/Images/HowToLaunch.png b/doc/Images/HowToLaunch.png new file mode 100644 index 0000000..b1db5b6 Binary files /dev/null and b/doc/Images/HowToLaunch.png differ diff --git a/src/EntityFramework_LoL/Sources/ApiLol/ApiLol.csproj b/src/EntityFramework_LoL/Sources/ApiLol/ApiLol.csproj index d01f0d6..b63bbf1 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/ApiLol.csproj +++ b/src/EntityFramework_LoL/Sources/ApiLol/ApiLol.csproj @@ -17,6 +17,7 @@ + diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/RunePagesController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/RunePagesController.cs index 426cedd..b52a0c7 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/RunePagesController.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/RunePagesController.cs @@ -1,4 +1,4 @@ -using ApiLol.Mapper; +using ApiMapping; using DTO; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/RunesController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/RunesController.cs index 8d7a2e4..8fba7ed 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/RunesController.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/RunesController.cs @@ -1,4 +1,4 @@ -using ApiLol.Mapper; +using ApiMapping; using DTO; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/SkinsController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/SkinsController.cs index eb9192a..537923b 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/SkinsController.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/SkinsController.cs @@ -1,4 +1,4 @@ -using ApiLol.Mapper; +using ApiMapping; using DTO; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/v1/ChampionsController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/v1/ChampionsController.cs index 2125c70..f33ee8d 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/v1/ChampionsController.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/v1/ChampionsController.cs @@ -1,4 +1,4 @@ -using ApiLol.Mapper; +using ApiMapping; using DTO; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/v2/ChampionsController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/v2/ChampionsController.cs index a9ca793..161a112 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/v2/ChampionsController.cs +++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/v2/ChampionsController.cs @@ -1,5 +1,4 @@ -using ApiLol.Mapper; -using Azure.Core; +using ApiMapping; using DTO; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; @@ -41,7 +40,7 @@ namespace ApiLol.Controllers.v2 return BadRequest($"Champion limit exceed, max {nbTotal}"); } - IEnumerable dtos = (await _manager.ChampionsMgr.GetItems(pageRequest.index, pageRequest.count)) + IEnumerable dtos = (await _manager.ChampionsMgr.GetItems(pageRequest.index, pageRequest.count, pageRequest.orderingPropertyName, pageRequest.descending)) .Select(x => x.ToDto()); return Ok(dtos); } @@ -81,7 +80,7 @@ namespace ApiLol.Controllers.v2 dtos = (await _manager.ChampionsMgr.GetItemsByName(pageRequest.name, pageRequest.index, pageRequest.count, pageRequest.orderingPropertyName, pageRequest.descending)) .Select(x => x.ToDto()); } - return Ok(new PageResponse{ Data = dtos, index = pageRequest.index, count = pageRequest.count, total = nbTotal }); + return Ok(new PageResponse { Data = dtos, index = pageRequest.index, count = pageRequest.count, total = nbTotal }); } catch (Exception error) { diff --git a/src/EntityFramework_LoL/Sources/ApiMapping/ApiMapping.csproj b/src/EntityFramework_LoL/Sources/ApiMapping/ApiMapping.csproj new file mode 100644 index 0000000..65895ab --- /dev/null +++ b/src/EntityFramework_LoL/Sources/ApiMapping/ApiMapping.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/ChampionMapper.cs similarity index 94% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/ChampionMapper.cs index 9b48da4..524dfcc 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/ChampionMapper.cs @@ -1,40 +1,42 @@ -using DTO; -using Model; - -namespace ApiLol.Mapper -{ - public static class ChampionMapper - { - public static ChampionDto ToDto(this Champion champion) - => new() - { - Name = champion.Name, - Bio = champion.Bio, - Class = champion.Class.ToDto(), - Icon = champion.Icon, - Image = champion.Image.ToDto(), - Skins = champion.Skins.Select(e => e.ToDto()), - Skills = champion.Skills.Select(e => e.ToDto()), - Characteristics = champion.Characteristics.ToDictionary(c => c.Key, c => c.Value) - - }; - - - public static Champion ToModel(this ChampionDto championDto) - { - var champ = new Champion(championDto.Name, championDto.Class.ToModel(), championDto.Icon, championDto.Image.Base64, championDto.Bio); - foreach (var skin in championDto.Skins) - { - champ.AddSkin(skin.ToModel(champ)); - } - foreach (var skill in championDto.Skills) - { - champ.AddSkill(skill.ToModel()); - } - if (championDto.Characteristics != null) - champ.AddCharacteristics(championDto.Characteristics.Select(c => Tuple.Create(c.Key, c.Value)).ToArray()); - return champ; - } - - } -} +using ApiMapping; +using ApiMapping.enums; +using DTO; +using Model; + +namespace ApiMapping +{ + public static class ChampionMapper + { + public static ChampionDto ToDto(this Champion champion) + => new() + { + Name = champion.Name, + Bio = champion.Bio, + Class = champion.Class.ToDto(), + Icon = champion.Icon, + Image = champion.Image.ToDto(), + Skins = champion.Skins.Select(e => e.ToDto()), + Skills = champion.Skills.Select(e => e.ToDto()), + Characteristics = champion.Characteristics.ToDictionary(c => c.Key, c => c.Value) + + }; + + + public static Champion ToModel(this ChampionDto championDto) + { + var champ = new Champion(championDto.Name, championDto.Class.ToModel(), championDto.Icon, championDto.Image.Base64, championDto.Bio); + foreach (var skin in championDto.Skins) + { + champ.AddSkin(skin.ToModel(champ)); + } + foreach (var skill in championDto.Skills) + { + champ.AddSkill(skill.ToModel()); + } + if (championDto.Characteristics != null) + champ.AddCharacteristics(championDto.Characteristics.Select(c => Tuple.Create(c.Key, c.Value)).ToArray()); + return champ; + } + + } +} diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/LargeImageMapper.cs similarity index 92% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/LargeImageMapper.cs index a0b8756..44ee496 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/LargeImageMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/LargeImageMapper.cs @@ -1,7 +1,7 @@ using DTO; using Model; -namespace ApiLol.Mapper +namespace ApiMapping { public static class LargeImageMapper { diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/RuneMapper.cs similarity index 87% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/RuneMapper.cs index b11f1aa..8014276 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/RuneMapper.cs @@ -1,22 +1,23 @@ -using ApiLol.Mapper.enums; -using DTO; -using Model; - -namespace ApiLol.Mapper -{ - public static class RuneMapper - { - public static RuneDto ToDto(this Rune rune) - => new() - { - Name = rune.Name, - Description = rune.Description, - Family = rune.Family.ToDto(), - Icon = rune.Icon, - Image = rune.Image.ToDto() - }; - - public static Rune ToModel(this RuneDto rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description); - - } -} +using ApiMapping; +using ApiMapping.enums; +using DTO; +using Model; + +namespace ApiMapping +{ + public static class RuneMapper + { + public static RuneDto ToDto(this Rune rune) + => new() + { + Name = rune.Name, + Description = rune.Description, + Family = rune.Family.ToDto(), + Icon = rune.Icon, + Image = rune.Image.ToDto() + }; + + public static Rune ToModel(this RuneDto rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description); + + } +} diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RunePageMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/RunePageMapper.cs similarity index 94% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/RunePageMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/RunePageMapper.cs index 6ea2bd8..b54b126 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RunePageMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/RunePageMapper.cs @@ -1,9 +1,8 @@ -using ApiLol.Mapper.enums; -using DTO; +using DTO; using Model; using static Model.RunePage; -namespace ApiLol.Mapper +namespace ApiMapping { public static class RunePageMapper { diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/SkillMapper.cs similarity index 84% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/SkillMapper.cs index 27bb55b..1eee13c 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/SkillMapper.cs @@ -1,19 +1,21 @@ -using DTO; -using Model; - -namespace ApiLol.Mapper -{ - public static class SkillMapper - { - public static SkillDto ToDto(this Skill skill) - => new() - { - Name = skill.Name, - Description = skill.Description, - Type = skill.Type.ToDto() - }; - - public static Skill ToModel(this SkillDto skillDto) => new(skillDto.Name, skillDto.Type.ToModel(), skillDto.Description); - - } -} +using ApiMapping; +using ApiMapping.enums; +using DTO; +using Model; + +namespace ApiMapping +{ + public static class SkillMapper + { + public static SkillDto ToDto(this Skill skill) + => new() + { + Name = skill.Name, + Description = skill.Description, + Type = skill.Type.ToDto() + }; + + public static Skill ToModel(this SkillDto skillDto) => new(skillDto.Name, skillDto.Type.ToModel(), skillDto.Description); + + } +} diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/SkinMapper.cs similarity index 95% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/SkinMapper.cs index d4d7221..16249c3 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkinMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/SkinMapper.cs @@ -1,7 +1,8 @@ -using DTO; +using ApiMapping; +using DTO; using Model; -namespace ApiLol.Mapper +namespace ApiMapping { public static class SkinMapper { diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/CategoryMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/enums/CategoryMapper.cs similarity index 98% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/CategoryMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/enums/CategoryMapper.cs index 55dfe9f..10a5c8d 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/CategoryMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/enums/CategoryMapper.cs @@ -1,7 +1,7 @@ using DTO; using Model; -namespace ApiLol.Mapper.enums +namespace ApiMapping.enums { public static class CategoryMapper { diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/ChampionClassMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/enums/ChampionClassMapper.cs similarity index 96% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/ChampionClassMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/enums/ChampionClassMapper.cs index a61f12f..3ac6636 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/ChampionClassMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/enums/ChampionClassMapper.cs @@ -1,53 +1,53 @@ -using DTO; -using Model; - -namespace ApiLol.Mapper -{ - public static class ChampionClassMapper - { - public static ChampionClassDto ToDto(this ChampionClass championClass) - { - switch (championClass) - { - case ChampionClass.Unknown: - return ChampionClassDto.Unknown; - case ChampionClass.Assassin: - return ChampionClassDto.Assassin; - case ChampionClass.Fighter: - return ChampionClassDto.Fighter; - case ChampionClass.Mage: - return ChampionClassDto.Mage; - case ChampionClass.Marksman: - return ChampionClassDto.Marksman; - case ChampionClass.Support: - return ChampionClassDto.Support; - case ChampionClass.Tank: - return ChampionClassDto.Tank; - default: - return ChampionClassDto.Unknown; - } - } - public static ChampionClass ToModel(this ChampionClassDto championClass) - { - switch (championClass) - { - case ChampionClassDto.Unknown: - return ChampionClass.Unknown; - case ChampionClassDto.Assassin: - return ChampionClass.Assassin; - case ChampionClassDto.Fighter: - return ChampionClass.Fighter; - case ChampionClassDto.Mage: - return ChampionClass.Mage; - case ChampionClassDto.Marksman: - return ChampionClass.Marksman; - case ChampionClassDto.Support: - return ChampionClass.Support; - case ChampionClassDto.Tank: - return ChampionClass.Tank; - default: - return ChampionClass.Unknown; - } - } - } -} +using DTO; +using Model; + +namespace ApiMapping.enums +{ + public static class ChampionClassMapper + { + public static ChampionClassDto ToDto(this ChampionClass championClass) + { + switch (championClass) + { + case ChampionClass.Unknown: + return ChampionClassDto.Unknown; + case ChampionClass.Assassin: + return ChampionClassDto.Assassin; + case ChampionClass.Fighter: + return ChampionClassDto.Fighter; + case ChampionClass.Mage: + return ChampionClassDto.Mage; + case ChampionClass.Marksman: + return ChampionClassDto.Marksman; + case ChampionClass.Support: + return ChampionClassDto.Support; + case ChampionClass.Tank: + return ChampionClassDto.Tank; + default: + return ChampionClassDto.Unknown; + } + } + public static ChampionClass ToModel(this ChampionClassDto championClass) + { + switch (championClass) + { + case ChampionClassDto.Unknown: + return ChampionClass.Unknown; + case ChampionClassDto.Assassin: + return ChampionClass.Assassin; + case ChampionClassDto.Fighter: + return ChampionClass.Fighter; + case ChampionClassDto.Mage: + return ChampionClass.Mage; + case ChampionClassDto.Marksman: + return ChampionClass.Marksman; + case ChampionClassDto.Support: + return ChampionClass.Support; + case ChampionClassDto.Tank: + return ChampionClass.Tank; + default: + return ChampionClass.Unknown; + } + } + } +} diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/RuneFamilyMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/enums/RuneFamilyMapper.cs similarity index 97% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/RuneFamilyMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/enums/RuneFamilyMapper.cs index 00f550e..1876fc8 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/RuneFamilyMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/enums/RuneFamilyMapper.cs @@ -2,7 +2,7 @@ using DTO.enums; using Model; -namespace ApiLol.Mapper.enums +namespace ApiMapping.enums { public static class RuneFamilyMapper { diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/SkillTypeMapper.cs b/src/EntityFramework_LoL/Sources/ApiMapping/enums/SkillTypeMapper.cs similarity index 97% rename from src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/SkillTypeMapper.cs rename to src/EntityFramework_LoL/Sources/ApiMapping/enums/SkillTypeMapper.cs index c21be45..810f031 100644 --- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/enums/SkillTypeMapper.cs +++ b/src/EntityFramework_LoL/Sources/ApiMapping/enums/SkillTypeMapper.cs @@ -1,7 +1,7 @@ using DTO; using Model; -namespace ApiLol.Mapper +namespace ApiMapping.enums { public static class SkillTypeMapper { diff --git a/src/EntityFramework_LoL/Sources/Client/ApiManager.Champions.cs b/src/EntityFramework_LoL/Sources/Client/ApiManager.Champions.cs new file mode 100644 index 0000000..8e2b469 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Client/ApiManager.Champions.cs @@ -0,0 +1,184 @@ +using ApiMapping; +using DTO; +using Model; +using System.Net.Http.Json; + +namespace ApiManager +{ + public partial class ApiManagerData + { + public class ChampionsManager : HttpClientManager, IChampionsManager + { + private const string UrlApiChampions = "/api/v2/champions"; + public ChampionsManager(HttpClient httpClient) : base(httpClient) { } + + public async Task AddItem(Champion? item) + { + try + { + var resp = await _httpClient.PostAsJsonAsync($"{UrlApiChampions}", item.ToDto()); + if (resp.IsSuccessStatusCode) + { + var createdItem = await resp.Content.ReadFromJsonAsync(); + return createdItem?.ToModel(); + } + else + { + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error adding champion: {ex.Message}"); + return null; + } + } + + public async Task DeleteItem(Champion? item) + { + try + { + var resp = await _httpClient.DeleteAsync($"{UrlApiChampions}/{item?.Name}"); + return resp.IsSuccessStatusCode; + } + catch (Exception ex) + { + Console.WriteLine($"Error deleting champion: {ex.Message}"); + return false; + } + } + + private Func filterByNameContains = (champ, substring) => champ.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase); + + private Func filterByName = (champ, substring) => champ.Name.Equals(substring, StringComparison.InvariantCultureIgnoreCase); + + public async Task> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return response.Select(c => c.ToModel()).GetItemsWithFilterAndOrdering(champ => filterByName(champ, substring), index, count, orderingPropertyName, descending); + } + + public async Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var url = $"{UrlApiChampions}?index={index}&count={count}&orderingPropertyName={orderingPropertyName}&descending={descending}"; + var response = await _httpClient.GetFromJsonAsync>(url); + return response.Select(c => c.ToModel()); + } + + private Func filterByCharacteristic = (champ, charName) => champ.Characteristics.Keys.Any(k => k.Contains(charName, StringComparison.InvariantCultureIgnoreCase)); + + public async Task> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return response.Select(c => c.ToModel()).GetItemsWithFilterAndOrdering( + champ => filterByCharacteristic(champ, charName), + index, count, orderingPropertyName, descending); + } + + private Func filterByClass = (champ, championClass) => champ.Class == championClass; + + public async Task> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return response.Select(c => c.ToModel()).GetItemsWithFilterAndOrdering( + champ => filterByClass(champ, championClass), + index, count, orderingPropertyName, descending); + } + + public async Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return response.Select(c => c.ToModel()).GetItemsWithFilterAndOrdering(champ => filterByNameContains(champ, substring), index, count, orderingPropertyName, descending); + } + + public async Task> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + private Func filterBySkill = (champ, skill) => skill != null && champ.Skills.Contains(skill!); + + private static Func filterBySkillSubstring = (champ, skill) => champ.Skills.Any(s => s.Name.Contains(skill, StringComparison.InvariantCultureIgnoreCase)); + + public async Task> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return response.Select(c => c.ToModel()).GetItemsWithFilterAndOrdering(champ => filterBySkill(champ, skill), index, count, orderingPropertyName, descending); + } + + public async Task> GetItemsBySkill(string skillSubstring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return response.Select(c => c.ToModel()).GetItemsWithFilterAndOrdering(champ => filterBySkillSubstring(champ, skillSubstring), index, count, orderingPropertyName, descending); + } + + public async Task GetNbItems() + { + var response = await _httpClient.GetAsync("/countChampions"); + var content = await response.Content.ReadAsStringAsync(); + return int.Parse(content); + } + + public async Task GetNbItemsByCharacteristic(string charName) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return await response.GetNbItemsWithFilter(champ => filterByCharacteristic(champ.ToModel(), charName)); + + } + + public async Task GetNbItemsByClass(ChampionClass championClass) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return response.Where(c => c.Class.Equals(championClass)) + .Count(); + } + + public async Task GetNbItemsByName(string substring) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return response.Where(c => c.Name.Equals(substring)) + .Count(); + } + + public Task GetNbItemsByRunePage(RunePage? runePage) + { + throw new NotImplementedException(); + } + + public async Task GetNbItemsBySkill(Skill? skill) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return await response.GetNbItemsWithFilter(champ => filterBySkill(champ.ToModel(), skill)); + } + + public async Task GetNbItemsBySkill(string skill) + { + var response = await _httpClient.GetFromJsonAsync>(UrlApiChampions); + return await response.GetNbItemsWithFilter(champ => filterBySkillSubstring(champ.ToModel(), skill)); + } + + public async Task UpdateItem(Champion? oldItem, Champion? newItem) + { + try + { + var resp = await _httpClient.PutAsJsonAsync($"{UrlApiChampions}/{oldItem?.Name}", newItem.ToDto()); + if (resp.IsSuccessStatusCode) + { + var updatedItem = await resp.Content.ReadFromJsonAsync(); + return updatedItem?.ToModel(); + } + else + { + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error updating champion: {ex.Message}"); + return null; + } + } + + } + } +} diff --git a/src/EntityFramework_LoL/Sources/Client/ApiManager.RunePages.cs b/src/EntityFramework_LoL/Sources/Client/ApiManager.RunePages.cs new file mode 100644 index 0000000..a7aa88d --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Client/ApiManager.RunePages.cs @@ -0,0 +1,145 @@ +using DTO; +using Model; +using System.Net.Http.Json; +using ApiMapping; +using System.Data.SqlTypes; + +namespace ApiManager +{ + public partial class ApiManagerData + { + public class RunePagesManager : HttpClientManager, IRunePagesManager + { + private const string UrlApiRunePages = "/api/RunePages"; + public RunePagesManager(HttpClient httpClient) : base(httpClient) { } + + public async Task AddItem(RunePage? item) + { + try + { + var resp = await _httpClient.PostAsJsonAsync($"{UrlApiRunePages}", item.ToDto()); + if (resp.IsSuccessStatusCode) + { + var createdItem = await resp.Content.ReadFromJsonAsync(); + return createdItem?.ToModel(); + } + else + { + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error adding runePage: {ex.Message}"); + return null; + } + } + + public async Task DeleteItem(RunePage? item) + { + try + { + var resp = await _httpClient.DeleteAsync($"{UrlApiRunePages}/{item?.Name}"); + return resp.IsSuccessStatusCode; + } + catch (Exception ex) + { + Console.WriteLine($"Error deleting runePage: {ex.Message}"); + return false; + } + } + + private static Func filterByName + = (rp, substring) => rp.Name.Equals(substring, StringComparison.InvariantCultureIgnoreCase); + + private static Func filterByNameContains + = (rp, substring) => rp.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase); + + private static Func filterByRune + = (rp, rune) => rune != null && rp.Runes.Values.Contains(rune!); + + public async Task> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var runePages = await _httpClient.GetFromJsonAsync>(UrlApiRunePages); + return runePages.Data.Select(r => r.ToModel()).GetItemsWithFilterAndOrdering( + rp => filterByName(rp, substring), + index, count, orderingPropertyName, descending); + } + + public async Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var runePages = await _httpClient.GetFromJsonAsync>($"{UrlApiRunePages}?&index={index}&count={count}&descending={descending}"); + return runePages.Data.Select(c => c.ToModel()); + } + + public async Task> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + throw new NotImplementedException(); + } + + public async Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var runePages = await _httpClient.GetFromJsonAsync>(UrlApiRunePages); + return runePages.Data.Select(r => r.ToModel()).GetItemsWithFilterAndOrdering( + rp => filterByNameContains(rp, substring), + index, count, orderingPropertyName, descending); + } + + public async Task> GetItemsByRune(Rune? rune, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var runePages = await _httpClient.GetFromJsonAsync>(UrlApiRunePages); + return runePages.Data.Select(r => r.ToModel()).GetItemsWithFilterAndOrdering( + rp => filterByRune(rp, rune), + index, count, orderingPropertyName, descending); + } + + public async Task GetNbItems() + { + var response = await _httpClient.GetAsync("/countRunePages"); + var content = await response.Content.ReadAsStringAsync(); + return int.Parse(content); + } + + public Task GetNbItemsByChampion(Champion? champion) + { + throw new NotImplementedException(); + } + + public async Task GetNbItemsByName(string substring) + { + var runePages = await _httpClient.GetFromJsonAsync>(UrlApiRunePages); + return await runePages.Data.Select(r => r.ToModel()).GetNbItemsWithFilter( + rp => filterByName(rp, substring)); + } + + public async Task GetNbItemsByRune(Rune? rune) + { + var runePages = await _httpClient.GetFromJsonAsync>(UrlApiRunePages); + return await runePages.Data.Select(r => r.ToModel()).GetNbItemsWithFilter( + rp => filterByRune(rp, rune)); + } + + public async Task UpdateItem(RunePage? oldItem, RunePage? newItem) + { + try + { + var resp = await _httpClient.PutAsJsonAsync($"{UrlApiRunePages}/{oldItem?.Name}", newItem.ToDto()); + if (resp.IsSuccessStatusCode) + { + var updatedItem = await resp.Content.ReadFromJsonAsync(); + return updatedItem?.ToModel(); + } + else + { + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error updating runePage: {ex.Message}"); + return null; + } + } + } + } +} diff --git a/src/EntityFramework_LoL/Sources/Client/ApiManager.Runes.cs b/src/EntityFramework_LoL/Sources/Client/ApiManager.Runes.cs new file mode 100644 index 0000000..086aed9 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Client/ApiManager.Runes.cs @@ -0,0 +1,138 @@ +using DTO; +using Model; +using System.Net.Http.Json; +using ApiMapping; +using System; +using System.Data.SqlTypes; +using Microsoft.EntityFrameworkCore.Metadata.Internal; + +namespace ApiManager +{ + public partial class ApiManagerData + { + public class RunesManager : HttpClientManager, IRunesManager + { + private const string UrlApiRunes = "/api/runes"; + public RunesManager(HttpClient httpClient) : base(httpClient) { } + + public async Task AddItem(Rune? item) + { + try + { + var resp = await _httpClient.PostAsJsonAsync($"{UrlApiRunes}", item.ToDto()); + if (resp.IsSuccessStatusCode) + { + var createdItem = await resp.Content.ReadFromJsonAsync(); + return createdItem?.ToModel(); + } + else + { + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error adding rune: {ex.Message}"); + return null; + } + } + + public async Task DeleteItem(Rune? item) + { + try + { + var resp = await _httpClient.DeleteAsync($"{UrlApiRunes}/{item?.Name}"); + return resp.IsSuccessStatusCode; + } + catch (Exception ex) + { + Console.WriteLine($"Error deleting rune: {ex.Message}"); + return false; + } + } + + private static Func filterByRuneFamily + = (rune, family) => rune.Family == family; + + private static Func filterByName + = (rune, substring) => rune.Name.Equals(substring, StringComparison.InvariantCultureIgnoreCase); + + private static Func filterByNameContains + = (rune, substring) => rune.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase); + + public async Task> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var runes = await _httpClient.GetFromJsonAsync>(UrlApiRunes); + return runes.Data.Select(r => r.ToModel()).GetItemsWithFilterAndOrdering( + rune => filterByName(rune, substring), + index, count, orderingPropertyName, descending); + } + + public async Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var runes = await _httpClient.GetFromJsonAsync>($"{UrlApiRunes}?&index={index}&count={count}&descending={descending}"); + return runes.Data.Select(c => c.ToModel()); + + } + + public async Task> GetItemsByFamily(RuneFamily family, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var runes = await _httpClient.GetFromJsonAsync>(UrlApiRunes); + return runes.Data.Select(r => r.ToModel()).GetItemsWithFilterAndOrdering( + rune => filterByRuneFamily(rune, family), + index, count, orderingPropertyName, descending); + } + + public async Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var runes = await _httpClient.GetFromJsonAsync>(UrlApiRunes); + return runes.Data.Select(r => r.ToModel()).GetItemsWithFilterAndOrdering( + rune => filterByNameContains(rune, substring), + index, count, orderingPropertyName, descending); + } + + public async Task GetNbItems() + { + var response = await _httpClient.GetAsync("/countRunes"); + var content = await response.Content.ReadAsStringAsync(); + return int.Parse(content); + } + + public async Task GetNbItemsByFamily(RuneFamily family) + { + var runes = await _httpClient.GetFromJsonAsync>(UrlApiRunes); + return await runes.Data.Select(r => r.ToModel()).GetNbItemsWithFilter( + rune => filterByRuneFamily(rune, family)); + } + + public async Task GetNbItemsByName(string substring) + { + var runes = await _httpClient.GetFromJsonAsync>(UrlApiRunes); + return await runes.Data.Select(r => r.ToModel()).GetNbItemsWithFilter( + rune => filterByName(rune, substring)); + } + + public async Task UpdateItem(Rune? oldItem, Rune? newItem) + { + try + { + var resp = await _httpClient.PutAsJsonAsync($"{UrlApiRunes}/{oldItem?.Name}", newItem.ToDto()); + if (resp.IsSuccessStatusCode) + { + var updatedItem = await resp.Content.ReadFromJsonAsync(); + return updatedItem?.ToModel(); + } + else + { + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error updating rune: {ex.Message}"); + return null; + } + } + } + } +} \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/Client/ApiManager.Skins.cs b/src/EntityFramework_LoL/Sources/Client/ApiManager.Skins.cs new file mode 100644 index 0000000..1153fca --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Client/ApiManager.Skins.cs @@ -0,0 +1,178 @@ +using DTO; +using Model; +using System.Net.Http.Json; +using ApiMapping; +using System.Data.SqlTypes; + +namespace ApiManager +{ + public partial class ApiManagerData + { + public class SkinsManager : HttpClientManager, ISkinsManager + { + private const string UrlApiSkins = "/api/Skins"; + public SkinsManager(HttpClient httpClient) : base(httpClient) { } + + public async Task AddItem(Skin? item) + { + try + { + var resp = await _httpClient.PostAsJsonAsync($"{UrlApiSkins}", item.ToDtoC()); + if (resp.IsSuccessStatusCode) + { + var createdItem = await resp.Content.ReadFromJsonAsync(); + var championManager = new ChampionsManager(_httpClient); + var champ = await championManager.GetItemByName(createdItem.ChampionName, 0, 1); + return createdItem?.ToModelC(champ.First()); + } + else + { + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error adding skin: {ex.Message}"); + return null; + } + } + + public async Task DeleteItem(Skin? item) + { + try + { + var resp = await _httpClient.DeleteAsync($"{UrlApiSkins}/{item?.Name}"); + return resp.IsSuccessStatusCode; + } + catch (Exception ex) + { + Console.WriteLine($"Error deleting skin: {ex.Message}"); + return false; + } + } + + public async Task> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var dtoSkins = await _httpClient.GetFromJsonAsync>(UrlApiSkins); + var skins = new List(); + var championManager = new ChampionsManager(_httpClient); + foreach (var skin in dtoSkins.Data) + { + var champ = await championManager.GetItemByName(skin.ChampionName, 0, 1); + skins.Add(skin.ToModelC(champ.First())); + } + return skins.GetItemsWithFilterAndOrdering( + skin => filterByName(skin, substring), + index, count, orderingPropertyName, descending); + } + + public async Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var dtoSkins = await _httpClient.GetFromJsonAsync>($"{UrlApiSkins}?&index={index}&count={count}&descending={descending}"); + var skins = new List(); + var championManager = new ChampionsManager(_httpClient); + foreach (var skin in dtoSkins.Data) + { + var champ = await championManager.GetItemByName(skin.ChampionName, 0, 1); + skins.Add(skin.ToModelC(champ.First())); + } + return skins; + } + + public async Task> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var dtoSkins = await _httpClient.GetFromJsonAsync>(UrlApiSkins); + var skins = new List(); + var championManager = new ChampionsManager(_httpClient); + foreach (var skin in dtoSkins.Data) + { + var champ = await championManager.GetItemByName(skin.ChampionName, 0, 1); + skins.Add(skin.ToModelC(champ.First())); + } + return skins.GetItemsWithFilterAndOrdering( + skin => filterByChampion(skin, champion), + index, count, orderingPropertyName, descending); + } + + private static Func filterByChampion = (skin, champion) => champion != null && skin.Champion.Equals(champion!); + + private static Func filterByName = (skin, substring) => skin.Name.Equals(substring, StringComparison.InvariantCultureIgnoreCase); + + private static Func filterByNameContains = (skin, substring) => skin.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase); + + public async Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + var dtoSkins = await _httpClient.GetFromJsonAsync>(UrlApiSkins); + var skins = new List(); + var championManager = new ChampionsManager(_httpClient); + foreach (var skin in dtoSkins.Data) + { + var champ = await championManager.GetItemByName(skin.ChampionName,0,1); + skins.Add(skin.ToModelC(champ.First())); + } + return skins.GetItemsWithFilterAndOrdering( + skin => filterByNameContains(skin, substring), + index, count, orderingPropertyName, descending); + } + + public async Task GetNbItems() + { + var response = await _httpClient.GetAsync("/countSkins"); + var content = await response.Content.ReadAsStringAsync(); + return int.Parse(content); + } + + public async Task GetNbItemsByChampion(Champion? champion) + { + var dtoSkins = await _httpClient.GetFromJsonAsync>(UrlApiSkins); + var skins = new List(); + var championManager = new ChampionsManager(_httpClient); + foreach (var skin in dtoSkins.Data) + { + var champ = await championManager.GetItemByName(skin.ChampionName, 0, 1); + skins.Add(skin.ToModelC(champ.First())); + } + return await skins.GetNbItemsWithFilter( + skin => filterByChampion(skin, champion)); + } + + public async Task GetNbItemsByName(string substring) + { + var dtoSkins = await _httpClient.GetFromJsonAsync>(UrlApiSkins); + var skins = new List(); + var championManager = new ChampionsManager(_httpClient); + foreach (var skin in dtoSkins.Data) + { + var champ = await championManager.GetItemByName(skin.ChampionName, 0, 1); + skins.Add(skin.ToModelC(champ.First())); + } + return await skins.GetNbItemsWithFilter( + skin => filterByName(skin, substring)); + } + + public async Task UpdateItem(Skin? oldItem, Skin? newItem) + { + try + { + var resp = await _httpClient.PutAsJsonAsync($"{UrlApiSkins}/{oldItem?.Name}", newItem.ToDto()); + if (resp.IsSuccessStatusCode) + { + var updatedItem = await resp.Content.ReadFromJsonAsync(); + var championManager = new ChampionsManager(_httpClient); + var champ = await championManager.GetItemByName(updatedItem.ChampionName, 0, 1); + return updatedItem?.ToModelC(champ.First()); + } + else + { + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error updating skin: {ex.Message}"); + return null; + } + } + } + } +} diff --git a/src/EntityFramework_LoL/Sources/Client/ApiManager.csproj b/src/EntityFramework_LoL/Sources/Client/ApiManager.csproj index ea66df3..61b1c54 100644 --- a/src/EntityFramework_LoL/Sources/Client/ApiManager.csproj +++ b/src/EntityFramework_LoL/Sources/Client/ApiManager.csproj @@ -1,15 +1,15 @@ - Exe net6.0 enable enable - + + diff --git a/src/EntityFramework_LoL/Sources/Client/ApiManagerData.cs b/src/EntityFramework_LoL/Sources/Client/ApiManagerData.cs new file mode 100644 index 0000000..b6bf39c --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Client/ApiManagerData.cs @@ -0,0 +1,24 @@ +using Model; + +namespace ApiManager +{ + public partial class ApiManagerData : IDataManager + { + public ApiManagerData(HttpClient httpClient) + { + ChampionsMgr = new ChampionsManager(httpClient); + SkinsMgr = new SkinsManager(httpClient); + RunesMgr = new RunesManager(httpClient); + RunePagesMgr = new RunePagesManager(httpClient); + + } + + public IChampionsManager ChampionsMgr { get; set; } + + public ISkinsManager SkinsMgr { get; set; } + + public IRunesManager RunesMgr { get; set; } + + public IRunePagesManager RunePagesMgr { get; set; } + } +} diff --git a/src/EntityFramework_LoL/Sources/Client/ChampionHttpClient.cs b/src/EntityFramework_LoL/Sources/Client/ChampionHttpClient.cs deleted file mode 100644 index c1e2f46..0000000 --- a/src/EntityFramework_LoL/Sources/Client/ChampionHttpClient.cs +++ /dev/null @@ -1,43 +0,0 @@ -using DTO; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http.Json; -using System.Text; -using System.Threading.Tasks; - -namespace Client -{ - public class ChampionHttpClient - { - private const string UrlApiChampions = "/api/v3/champions"; - private readonly HttpClient _httpClient; - public ChampionHttpClient(HttpClient httpClient) - { - _httpClient = httpClient; - httpClient.BaseAddress = new Uri("https://localhost:7252"); - } - - public async Task> GetChampion(int index, int count) - { - var url = $"{UrlApiChampions}?index={index}&count={count}"; - var Response = await _httpClient.GetFromJsonAsync>(url); - return Response.Data; - } - /* public async void Add(ChampionDto champion) - { - await _httpClient.PostAsJsonAsync(ApiChampions, champion); - }*/ - - /* public async void Delete(ChampionDto champion) - { - await _httpClient.DeleteAsync(champion.Name); - } - - public async void Update(ChampionDto champion) - { - await _httpClient.PutAsJsonAsync(ApiChampions, champion); - }*/ - - } -} diff --git a/src/EntityFramework_LoL/Sources/Client/Extensions.cs b/src/EntityFramework_LoL/Sources/Client/Extensions.cs new file mode 100644 index 0000000..48eee88 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Client/Extensions.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ApiManager +{ + static class Extensions + { + internal static IEnumerable GetItemsWithFilterAndOrdering(this IEnumerable collection, + Func filter, int index, int count, string? orderingPropertyName = null, bool descending = false) + { + IEnumerable temp = collection; + temp = temp.Where(item => filter(item)); + if (orderingPropertyName != null) + { + var prop = typeof(T).GetProperty(orderingPropertyName!); + if (prop != null) + { + temp = descending ? temp.OrderByDescending(item => prop.GetValue(item)) + : temp.OrderBy(item => prop.GetValue(item)); + } + } + return temp.Skip(index * count).Take(count); + } + + internal static Task GetNbItemsWithFilter(this IEnumerable collection, Func filter) + { + return Task.FromResult(collection.Count(item => filter(item))); + } + } +} diff --git a/src/EntityFramework_LoL/Sources/Client/HttpClientManager.cs b/src/EntityFramework_LoL/Sources/Client/HttpClientManager.cs new file mode 100644 index 0000000..e9de76a --- /dev/null +++ b/src/EntityFramework_LoL/Sources/Client/HttpClientManager.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ApiManager +{ + public class HttpClientManager + { + protected readonly HttpClient _httpClient; + + public HttpClientManager(HttpClient httpClient) + { + _httpClient = httpClient; + _httpClient.BaseAddress = new Uri("https://localhost:7252"); + } + } +} diff --git a/src/EntityFramework_LoL/Sources/Client/Program.cs b/src/EntityFramework_LoL/Sources/Client/Program.cs index 70ce525..d55ea82 100644 --- a/src/EntityFramework_LoL/Sources/Client/Program.cs +++ b/src/EntityFramework_LoL/Sources/Client/Program.cs @@ -1,19 +1,18 @@ -// See https://aka.ms/new-console-template for more information -using Client; -using DTO; +/*// See https://aka.ms/new-console-template for more information +using static ApiManager.ApiManagerData; Console.WriteLine("Hello, World!"); -var championClient = new ChampionHttpClient(new HttpClient()); +var championClient = new ChampionsManager(new HttpClient()); // Get all champions -var champions = await championClient.GetChampion(0,6); +var champions = await championClient.GetItems(0,6); Console.WriteLine("All champions:"); foreach (var champion in champions) { Console.WriteLine($"{champion.Name} ({champion.Bio})"); } -/*// Add a new champion +*//*// Add a new champion var newChampion = new ChampionDto { Name = "Akali", Role = "Assassin" }; championClient.Add(newChampion); @@ -34,6 +33,6 @@ if (championToUpdate != null) Console.WriteLine($"{championToUpdate.Name} updated."); } -*/ +*//* -Console.ReadLine(); \ No newline at end of file +Console.ReadLine();*/ \ No newline at end of file diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.RunePages.cs b/src/EntityFramework_LoL/Sources/DbManager/DbManager.RunePages.cs index efdfc20..1c13a0d 100644 --- a/src/EntityFramework_LoL/Sources/DbManager/DbManager.RunePages.cs +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.RunePages.cs @@ -47,9 +47,12 @@ namespace DbLib index, count, orderingPropertyName, descending).Select(c => c.ToModel(parent.DbContext)); public async Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) - => parent.DbContext.RunePages.Include(rp => rp.Champions).Include(rp => rp.DictionaryCategoryRunes).GetItemsWithFilterAndOrdering( + { + parent.DbContext.Runes.Include(r => r.Image); + return parent.DbContext.RunePages.Include(rp => rp.Champions).Include(rp => rp.DictionaryCategoryRunes).Include(rp => rp.DictionaryCategoryRunes).GetItemsWithFilterAndOrdering( rp => true, index, count, orderingPropertyName, descending).Select(c => c.ToModel(parent.DbContext)); + } public async Task> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false) => parent.DbContext.RunePages.Include(rp => rp.Champions).Include(rp => rp.DictionaryCategoryRunes).GetItemsWithFilterAndOrdering( diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.cs b/src/EntityFramework_LoL/Sources/DbManager/DbManager.cs index 8ad6f6b..d62622b 100644 --- a/src/EntityFramework_LoL/Sources/DbManager/DbManager.cs +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.cs @@ -1,5 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Model; +using Model; using MyFlib; namespace DbLib diff --git a/src/EntityFramework_LoL/Sources/DbManager/DbManager.csproj b/src/EntityFramework_LoL/Sources/DbManager/DbManager.csproj index 48db0d4..84e1abb 100644 --- a/src/EntityFramework_LoL/Sources/DbManager/DbManager.csproj +++ b/src/EntityFramework_LoL/Sources/DbManager/DbManager.csproj @@ -1,7 +1,6 @@ - Exe net6.0 enable enable diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/ChampionMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/ChampionMapper.cs index 71755f5..d9a395b 100644 --- a/src/EntityFramework_LoL/Sources/DbManager/Mapper/ChampionMapper.cs +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/ChampionMapper.cs @@ -15,7 +15,7 @@ namespace DbManager.Mapper } foreach (var skin in championEntity.Skins) { - champion.AddSkin(new Skin(skin.Name, champion, skin.Price, skin.Icon, skin.Image.Base64, skin.Description)); + champion.AddSkin(new Skin(skin.Name, champion, skin.Price, skin.Icon, "", skin.Description)); } if (championEntity.Characteristics != null) { diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/RuneMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/RuneMapper.cs index 788ce1e..744c73f 100644 --- a/src/EntityFramework_LoL/Sources/DbManager/Mapper/RuneMapper.cs +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/RuneMapper.cs @@ -6,7 +6,7 @@ namespace DbManager.Mapper { public static class RuneMapper { - public static Rune ToModel(this RuneEntity rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description); + public static Rune ToModel(this RuneEntity rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, "", rune.Description); public static RuneEntity ToEntity(this Rune rune) => new() { diff --git a/src/EntityFramework_LoL/Sources/DbManager/Mapper/RunePageMapper.cs b/src/EntityFramework_LoL/Sources/DbManager/Mapper/RunePageMapper.cs index d485243..a5d2025 100644 --- a/src/EntityFramework_LoL/Sources/DbManager/Mapper/RunePageMapper.cs +++ b/src/EntityFramework_LoL/Sources/DbManager/Mapper/RunePageMapper.cs @@ -1,4 +1,5 @@ using DbManager.Mapper.enums; +using Microsoft.EntityFrameworkCore; using Model; using MyFlib; using MyFlib.Entities; diff --git a/src/EntityFramework_LoL/Sources/DbManager/Program.cs b/src/EntityFramework_LoL/Sources/DbManager/Program.cs deleted file mode 100644 index 3751555..0000000 --- a/src/EntityFramework_LoL/Sources/DbManager/Program.cs +++ /dev/null @@ -1,2 +0,0 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); diff --git a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln index 339d0ce..0b6b133 100644 --- a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln +++ b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln @@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LolApp", "LolApp\LolApp.csp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViewModels", "ViewModels\ViewModels.csproj", "{65135247-E1AB-4EE4-9473-DFDE6AFCC250}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiMapping", "ApiMapping\ApiMapping.csproj", "{F8D44A32-788B-4E63-B379-278B90216E28}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -93,6 +95,10 @@ Global {65135247-E1AB-4EE4-9473-DFDE6AFCC250}.Debug|Any CPU.Build.0 = Debug|Any CPU {65135247-E1AB-4EE4-9473-DFDE6AFCC250}.Release|Any CPU.ActiveCfg = Release|Any CPU {65135247-E1AB-4EE4-9473-DFDE6AFCC250}.Release|Any CPU.Build.0 = Release|Any CPU + {F8D44A32-788B-4E63-B379-278B90216E28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8D44A32-788B-4E63-B379-278B90216E28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8D44A32-788B-4E63-B379-278B90216E28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8D44A32-788B-4E63-B379-278B90216E28}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/EntityFramework_LoL/Sources/LolApp/LolApp.csproj b/src/EntityFramework_LoL/Sources/LolApp/LolApp.csproj index ab4fa0c..cc14a27 100644 --- a/src/EntityFramework_LoL/Sources/LolApp/LolApp.csproj +++ b/src/EntityFramework_LoL/Sources/LolApp/LolApp.csproj @@ -82,6 +82,7 @@ + diff --git a/src/EntityFramework_LoL/Sources/LolApp/MauiProgram.cs b/src/EntityFramework_LoL/Sources/LolApp/MauiProgram.cs index c12deff..7a3494e 100644 --- a/src/EntityFramework_LoL/Sources/LolApp/MauiProgram.cs +++ b/src/EntityFramework_LoL/Sources/LolApp/MauiProgram.cs @@ -1,39 +1,38 @@ -using CommunityToolkit.Maui; -using LolApp.ViewModels; -using Microsoft.Extensions.Logging; -using Microsoft.Maui.Handlers; -using Microsoft.Maui.Platform; -using Model; -using StubLib; -using ViewModels; - -namespace LolApp; - -public static class MauiProgram -{ - public static MauiApp CreateMauiApp() - { - var builder = MauiApp.CreateBuilder(); - builder - .UseMauiApp() - .UseMauiCommunityToolkit() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); - fonts.AddFont("Font Awesome 6 Free-Solid-900.otf", "FASolid"); - }); - builder.Services.AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton(); - -#if DEBUG - builder.Logging.AddDebug(); -#endif - - return builder.Build(); - } -} - +using ApiManager; +using CommunityToolkit.Maui; +using LolApp.ViewModels; +using Microsoft.Extensions.Logging; +using Model; +using StubLib; +using ViewModels; + +namespace LolApp; + +public static class MauiProgram +{ + public static MauiApp CreateMauiApp() + { + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .UseMauiCommunityToolkit() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); + fonts.AddFont("Font Awesome 6 Free-Solid-900.otf", "FASolid"); + }); + builder.Services.AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton(); + +#if DEBUG + builder.Logging.AddDebug(); +#endif + + return builder.Build(); + } +} + diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db index d3b2cb4..df215a3 100644 Binary files a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db and b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db differ diff --git a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs index 2a3ebb1..96aac02 100644 --- a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs +++ b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs @@ -33,8 +33,8 @@ namespace MyFlib protected override void OnModelCreating(ModelBuilder modelBuilder) { //LargeImageEntity - LargeImageEntity image1 = new LargeImageEntity { Id = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}"), Base64 = "empty" }; - LargeImageEntity image2 = new LargeImageEntity { Id = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}"), Base64 = " " }; + LargeImageEntity image1 = new LargeImageEntity { Id = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}"), Base64 = "UklGRtwDAABXRUJQVlA4INADAAAwEACdASoqACoAAMASJZgCdMoSCz655ndU4XXAP2yXIge5neM/Qd6WCfO8evoj2S0A/p7+f0An85cBxlLDgPC8jO/0nsl/13/O8vvzj7Af8s/p3/H4FU6td4MCwq23z1H2uzoKIXaqJniPI/bRMf8qzv0Zp+HE1RCBw5WQ1j/JovdM1FS52+QcaAAA/v/+NxU4DpPk3+xQPW7tcmURSo9vC4qc+XMxNVBzEM5E8actDz98gmwTXgD62e9EmG/ervdd2ovFFSuxYppWl/wtaX3rkn0xrt8qOql/5I2jfLOnCU0kALLcW4F/wTjU10qsxZXW9fxauC6OPVRF28sc94V9ocmoSWy+sf6jW3vYkVOh+gE/RE0L6b2d3oFyHmkRJnfYwG8o3p6fv9pivNF5aopIBzFnjzwb/VqSq3/b+MWKFmjr8T1qe4/fITo2vBWEqDyogV3ZVGnDVi2DbiEFVSUr2eXTNZQ9V/D9QC/+vCR5TGyX9QOVBgtAYtm/ZTIwzPEYB9NrV1NeO1/sAz78u0tW59r0I+SO5Jgm3B9i1toRurzHv9EZJ9yZL8nafb/T1FaoPDkuJfM+iPs0j8xnS7TaU/gEK0wCxeDYRYtJx9j4hUQq7pAu/T2yWy0vjcUHki952ZNbXnXxB8m8pV5x9E1sfLj5MZEgpU2XV8RHrVvWniCjsf6vgxmR7+KtwIbMjahitUGtHet1WdL+8MmdL29iQJC37pDXirir1NibxKKhFYRuJ3xW9O0r9+Vnh8diqbBuXqDbYR/MSoHvscOCm2t95dN5WBdRUoD7YCG/ZHWc7Ypv/x/al4fkB2lZlYhVWHxjaoeF9jEPI0gAN5XsvUI6hbzEzWMsNW/1orkNOnlskalgmpI4B2rm4Gc7LNui+MuMBrpnBvLkbYX9exe9g8tu7wLt7ScOjDcL99oOyR89Mh9L8rd4+43+JQyR6tsIfcPJo6T6FxHf11d/MGayJi+SWct/uhvvua0oOh+zXNIaUzgoBmu1XULjkpuA0Ghzctf30jbY1AOM49qbMZRYS9A+0S1HrHPnwRvpQY/Sj4xKPn0gdpv/+iTbKJb8zkPC4/9af0Jvesa+GDG0/iw3TswenMhqlh7BM9MW5txpeblsByx4WnJ/oHv6cc0dmM7tsV36lYkCTUXEf/0eKlnfivnN0g1g+j/Lk9et/uoa6TFCW0HgwFOIVFumEYdT675PfuTrYO5o8ZrWEIHtv2Ctlrv9J3TrslD/iKEwtipGHtn0Vak8B9wLL+kz+CIQ/VG4KJpXjx88CeCC4XaGitEdjAAA" }; + LargeImageEntity image2 = new LargeImageEntity { Id = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}"), Base64 = "UklGRtwDAABXRUJQVlA4INADAAAwEACdASoqACoAAMASJZgCdMoSCz655ndU4XXAP2yXIge5neM/Qd6WCfO8evoj2S0A/p7+f0An85cBxlLDgPC8jO/0nsl/13/O8vvzj7Af8s/p3/H4FU6td4MCwq23z1H2uzoKIXaqJniPI/bRMf8qzv0Zp+HE1RCBw5WQ1j/JovdM1FS52+QcaAAA/v/+NxU4DpPk3+xQPW7tcmURSo9vC4qc+XMxNVBzEM5E8actDz98gmwTXgD62e9EmG/ervdd2ovFFSuxYppWl/wtaX3rkn0xrt8qOql/5I2jfLOnCU0kALLcW4F/wTjU10qsxZXW9fxauC6OPVRF28sc94V9ocmoSWy+sf6jW3vYkVOh+gE/RE0L6b2d3oFyHmkRJnfYwG8o3p6fv9pivNF5aopIBzFnjzwb/VqSq3/b+MWKFmjr8T1qe4/fITo2vBWEqDyogV3ZVGnDVi2DbiEFVSUr2eXTNZQ9V/D9QC/+vCR5TGyX9QOVBgtAYtm/ZTIwzPEYB9NrV1NeO1/sAz78u0tW59r0I+SO5Jgm3B9i1toRurzHv9EZJ9yZL8nafb/T1FaoPDkuJfM+iPs0j8xnS7TaU/gEK0wCxeDYRYtJx9j4hUQq7pAu/T2yWy0vjcUHki952ZNbXnXxB8m8pV5x9E1sfLj5MZEgpU2XV8RHrVvWniCjsf6vgxmR7+KtwIbMjahitUGtHet1WdL+8MmdL29iQJC37pDXirir1NibxKKhFYRuJ3xW9O0r9+Vnh8diqbBuXqDbYR/MSoHvscOCm2t95dN5WBdRUoD7YCG/ZHWc7Ypv/x/al4fkB2lZlYhVWHxjaoeF9jEPI0gAN5XsvUI6hbzEzWMsNW/1orkNOnlskalgmpI4B2rm4Gc7LNui+MuMBrpnBvLkbYX9exe9g8tu7wLt7ScOjDcL99oOyR89Mh9L8rd4+43+JQyR6tsIfcPJo6T6FxHf11d/MGayJi+SWct/uhvvua0oOh+zXNIaUzgoBmu1XULjkpuA0Ghzctf30jbY1AOM49qbMZRYS9A+0S1HrHPnwRvpQY/Sj4xKPn0gdpv/+iTbKJb8zkPC4/9af0Jvesa+GDG0/iw3TswenMhqlh7BM9MW5txpeblsByx4WnJ/oHv6cc0dmM7tsV36lYkCTUXEf/0eKlnfivnN0g1g+j/Lk9et/uoa6TFCW0HgwFOIVFumEYdT675PfuTrYO5o8ZrWEIHtv2Ctlrv9J3TrslD/iKEwtipGHtn0Vak8B9wLL+kz+CIQ/VG4KJpXjx88CeCC4XaGitEdjAAA" }; modelBuilder.Entity().HasData(image1, image2); diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230325231552_myMigration.Designer.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230325231552_myMigration.Designer.cs deleted file mode 100644 index 3cd96b3..0000000 --- a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230325231552_myMigration.Designer.cs +++ /dev/null @@ -1,671 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyFlib; - -#nullable disable - -namespace MyFlib.Migrations -{ - [DbContext(typeof(LolDbContext))] - [Migration("20230325231552_myMigration")] - partial class myMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("ChampionEntityRunePageEntity", b => - { - b.Property("ChampionsId") - .HasColumnType("TEXT"); - - b.Property("RunePagesName") - .HasColumnType("TEXT"); - - b.HasKey("ChampionsId", "RunePagesName"); - - b.HasIndex("RunePagesName"); - - b.ToTable("ChampionEntityRunePageEntity"); - }); - - modelBuilder.Entity("MyFlib.ChampionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("Bio") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.Property("Class") - .HasColumnType("INTEGER"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("Champions"); - - b.HasData( - new - { - Id = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Bio = "", - Class = 1, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Akali" - }, - new - { - Id = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Bio = "", - Class = 2, - Icon = "", - ImageId = new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), - Name = "Aatrox" - }, - new - { - Id = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Bio = "", - Class = 3, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Ahri" - }, - new - { - Id = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Bio = "", - Class = 4, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Akshan" - }, - new - { - Id = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Bio = "", - Class = 5, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Bard" - }, - new - { - Id = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Bio = "", - Class = 6, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Alistar" - }); - }); - - modelBuilder.Entity("MyFlib.DictionaryCategoryRune", b => - { - b.Property("RunePageName") - .HasColumnType("TEXT"); - - b.Property("RuneName") - .HasColumnType("TEXT"); - - b.Property("category") - .HasColumnType("INTEGER"); - - b.HasKey("RunePageName", "RuneName"); - - b.HasIndex("RuneName"); - - b.ToTable("CategoryRunes"); - - b.HasData( - new - { - RunePageName = "Page 1", - RuneName = "Hextech Flashtraption ", - category = 0 - }, - new - { - RunePageName = "Page 1", - RuneName = "Manaflow Band ", - category = 1 - }, - new - { - RunePageName = "Page 2", - RuneName = "Manaflow Band ", - category = 4 - }, - new - { - RunePageName = "Page 2", - RuneName = "Hextech Flashtraption ", - category = 5 - }); - }); - - modelBuilder.Entity("MyFlib.Entities.CharacteristicEntity", b => - { - b.Property("Name") - .HasMaxLength(254) - .HasColumnType("TEXT"); - - b.Property("ChampionForeignKey") - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("INTEGER"); - - b.HasKey("Name", "ChampionForeignKey"); - - b.HasIndex("ChampionForeignKey"); - - b.ToTable("Characteristic"); - - b.HasData( - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 58 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 92 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 6 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 526 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 418 - }, - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 68 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 0 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 1 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 570 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 350 - }, - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 70 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 0 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 1 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 580 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 0 - }, - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 56 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 0 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 1 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 575 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 200 - }, - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 63 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 0 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 2 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 573 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 278 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Value = 30 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Value = 1 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Value = 535 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Value = 350 - }); - }); - - modelBuilder.Entity("MyFlib.Entities.RunePageEntity", b => - { - b.Property("Name") - .HasMaxLength(64) - .HasColumnType("TEXT"); - - b.HasKey("Name"); - - b.ToTable("RunePages"); - - b.HasData( - new - { - Name = "Page 1" - }, - new - { - Name = "Page 2" - }); - }); - - modelBuilder.Entity("MyFlib.LargeImageEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("Base64") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("LargeImages"); - - b.HasData( - new - { - Id = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Base64 = "empty" - }, - new - { - Id = new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), - Base64 = " " - }); - }); - - modelBuilder.Entity("MyFlib.RuneEntity", b => - { - b.Property("Name") - .HasMaxLength(64) - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("Family") - .HasColumnType("INTEGER"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("TEXT"); - - b.HasKey("Name"); - - b.HasIndex("ImageId"); - - b.ToTable("Runes"); - - b.HasData( - new - { - Name = "Hextech Flashtraption ", - Description = "While Flash is on cooldown, it is replaced by Hexflash.", - Family = 0, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65") - }, - new - { - Name = "Manaflow Band ", - Description = "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", - Family = 2, - Icon = "", - ImageId = new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c") - }); - }); - - modelBuilder.Entity("MyFlib.SkillEntity", b => - { - b.Property("Name") - .HasMaxLength(64) - .HasColumnType("TEXT"); - - b.Property("ChampionForeignKey") - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("Name"); - - b.HasIndex("ChampionForeignKey"); - - b.ToTable("Skills"); - - b.HasData( - new - { - Name = "Boule de feu", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Description = "Fire!", - Type = 1 - }, - new - { - Name = "White Star", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Description = "Random damage", - Type = 3 - }); - }); - - modelBuilder.Entity("MyFlib.SkinEntity", b => - { - b.Property("Name") - .HasMaxLength(254) - .HasColumnType("TEXT"); - - b.Property("ChampionForeignKey") - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(1000) - .HasColumnType("TEXT"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("TEXT"); - - b.Property("Price") - .HasColumnType("REAL"); - - b.HasKey("Name"); - - b.HasIndex("ChampionForeignKey"); - - b.HasIndex("ImageId"); - - b.ToTable("Skins"); - - b.HasData( - new - { - Name = "Akali Infernale", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Description = "Djinn qu'on invoque en dessous du monde, l'Infernale connue sous le nom d'Akali réduira en cendres les ennemis de son maître… mais le prix de son service est toujours exorbitant.", - Icon = "empty", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Price = 520f - }, - new - { - Name = "Akshan Cyberpop", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Description = "Les bas-fonds d'Audio City ont un nouveau héros : le Rebelle fluo. Cette position, Akshan la doit à son courage, sa sagesse et sa capacité à s'infiltrer dans des bâtiments d'affaires hautement sécurisés, et ce, sans être repéré. Son charme ravageur l'a aussi beaucoup aidé.", - Icon = "empty", - ImageId = new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), - Price = 1350f - }); - }); - - modelBuilder.Entity("ChampionEntityRunePageEntity", b => - { - b.HasOne("MyFlib.ChampionEntity", null) - .WithMany() - .HasForeignKey("ChampionsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MyFlib.Entities.RunePageEntity", null) - .WithMany() - .HasForeignKey("RunePagesName") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("MyFlib.ChampionEntity", b => - { - b.HasOne("MyFlib.LargeImageEntity", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("MyFlib.DictionaryCategoryRune", b => - { - b.HasOne("MyFlib.RuneEntity", "rune") - .WithMany("DictionaryCategoryRunes") - .HasForeignKey("RuneName") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MyFlib.Entities.RunePageEntity", "runePage") - .WithMany("DictionaryCategoryRunes") - .HasForeignKey("RunePageName") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("rune"); - - b.Navigation("runePage"); - }); - - modelBuilder.Entity("MyFlib.Entities.CharacteristicEntity", b => - { - b.HasOne("MyFlib.ChampionEntity", "Champion") - .WithMany("Characteristics") - .HasForeignKey("ChampionForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Champion"); - }); - - modelBuilder.Entity("MyFlib.RuneEntity", b => - { - b.HasOne("MyFlib.LargeImageEntity", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("MyFlib.SkillEntity", b => - { - b.HasOne("MyFlib.ChampionEntity", "Champion") - .WithMany("Skills") - .HasForeignKey("ChampionForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Champion"); - }); - - modelBuilder.Entity("MyFlib.SkinEntity", b => - { - b.HasOne("MyFlib.ChampionEntity", "Champion") - .WithMany("Skins") - .HasForeignKey("ChampionForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MyFlib.LargeImageEntity", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Champion"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("MyFlib.ChampionEntity", b => - { - b.Navigation("Characteristics"); - - b.Navigation("Skills"); - - b.Navigation("Skins"); - }); - - modelBuilder.Entity("MyFlib.Entities.RunePageEntity", b => - { - b.Navigation("DictionaryCategoryRunes"); - }); - - modelBuilder.Entity("MyFlib.RuneEntity", b => - { - b.Navigation("DictionaryCategoryRunes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230325231552_myMigration.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230325231552_myMigration.cs deleted file mode 100644 index c5ed594..0000000 --- a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230325231552_myMigration.cs +++ /dev/null @@ -1,375 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace MyFlib.Migrations -{ - /// - public partial class myMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "LargeImages", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - Base64 = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_LargeImages", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "RunePages", - columns: table => new - { - Name = table.Column(type: "TEXT", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_RunePages", x => x.Name); - }); - - migrationBuilder.CreateTable( - name: "Champions", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", maxLength: 64, nullable: false), - Bio = table.Column(type: "TEXT", maxLength: 255, nullable: false), - Icon = table.Column(type: "TEXT", nullable: false), - Class = table.Column(type: "INTEGER", nullable: false), - ImageId = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Champions", x => x.Id); - table.ForeignKey( - name: "FK_Champions_LargeImages_ImageId", - column: x => x.ImageId, - principalTable: "LargeImages", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Runes", - columns: table => new - { - Name = table.Column(type: "TEXT", maxLength: 64, nullable: false), - Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), - Family = table.Column(type: "INTEGER", nullable: false), - Icon = table.Column(type: "TEXT", nullable: false), - ImageId = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Runes", x => x.Name); - table.ForeignKey( - name: "FK_Runes_LargeImages_ImageId", - column: x => x.ImageId, - principalTable: "LargeImages", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ChampionEntityRunePageEntity", - columns: table => new - { - ChampionsId = table.Column(type: "TEXT", nullable: false), - RunePagesName = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ChampionEntityRunePageEntity", x => new { x.ChampionsId, x.RunePagesName }); - table.ForeignKey( - name: "FK_ChampionEntityRunePageEntity_Champions_ChampionsId", - column: x => x.ChampionsId, - principalTable: "Champions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ChampionEntityRunePageEntity_RunePages_RunePagesName", - column: x => x.RunePagesName, - principalTable: "RunePages", - principalColumn: "Name", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Characteristic", - columns: table => new - { - Name = table.Column(type: "TEXT", maxLength: 254, nullable: false), - ChampionForeignKey = table.Column(type: "TEXT", nullable: false), - Value = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Characteristic", x => new { x.Name, x.ChampionForeignKey }); - table.ForeignKey( - name: "FK_Characteristic_Champions_ChampionForeignKey", - column: x => x.ChampionForeignKey, - principalTable: "Champions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Skills", - columns: table => new - { - Name = table.Column(type: "TEXT", maxLength: 64, nullable: false), - Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), - Type = table.Column(type: "INTEGER", nullable: false), - ChampionForeignKey = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Skills", x => x.Name); - table.ForeignKey( - name: "FK_Skills_Champions_ChampionForeignKey", - column: x => x.ChampionForeignKey, - principalTable: "Champions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Skins", - columns: table => new - { - Name = table.Column(type: "TEXT", maxLength: 254, nullable: false), - Description = table.Column(type: "TEXT", maxLength: 1000, nullable: false), - Icon = table.Column(type: "TEXT", nullable: false), - Price = table.Column(type: "REAL", nullable: false), - ChampionForeignKey = table.Column(type: "TEXT", nullable: false), - ImageId = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Skins", x => x.Name); - table.ForeignKey( - name: "FK_Skins_Champions_ChampionForeignKey", - column: x => x.ChampionForeignKey, - principalTable: "Champions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Skins_LargeImages_ImageId", - column: x => x.ImageId, - principalTable: "LargeImages", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CategoryRunes", - columns: table => new - { - RunePageName = table.Column(type: "TEXT", nullable: false), - RuneName = table.Column(type: "TEXT", nullable: false), - category = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CategoryRunes", x => new { x.RunePageName, x.RuneName }); - table.ForeignKey( - name: "FK_CategoryRunes_RunePages_RunePageName", - column: x => x.RunePageName, - principalTable: "RunePages", - principalColumn: "Name", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_CategoryRunes_Runes_RuneName", - column: x => x.RuneName, - principalTable: "Runes", - principalColumn: "Name", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "LargeImages", - columns: new[] { "Id", "Base64" }, - values: new object[,] - { - { new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), "empty" }, - { new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), " " } - }); - - migrationBuilder.InsertData( - table: "RunePages", - column: "Name", - values: new object[] - { - "Page 1", - "Page 2" - }); - - migrationBuilder.InsertData( - table: "Champions", - columns: new[] { "Id", "Bio", "Class", "Icon", "ImageId", "Name" }, - values: new object[,] - { - { new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), "", 6, "", new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), "Alistar" }, - { new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), "", 4, "", new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), "Akshan" }, - { new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), "", 1, "", new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), "Akali" }, - { new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), "", 5, "", new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), "Bard" }, - { new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), "", 2, "", new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), "Aatrox" }, - { new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), "", 3, "", new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), "Ahri" } - }); - - migrationBuilder.InsertData( - table: "Runes", - columns: new[] { "Name", "Description", "Family", "Icon", "ImageId" }, - values: new object[,] - { - { "Hextech Flashtraption ", "While Flash is on cooldown, it is replaced by Hexflash.", 0, "", new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65") }, - { "Manaflow Band ", "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", 2, "", new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c") } - }); - - migrationBuilder.InsertData( - table: "CategoryRunes", - columns: new[] { "RuneName", "RunePageName", "category" }, - values: new object[,] - { - { "Hextech Flashtraption ", "Page 1", 0 }, - { "Manaflow Band ", "Page 1", 1 }, - { "Hextech Flashtraption ", "Page 2", 5 }, - { "Manaflow Band ", "Page 2", 4 } - }); - - migrationBuilder.InsertData( - table: "Characteristic", - columns: new[] { "ChampionForeignKey", "Name", "Value" }, - values: new object[,] - { - { new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), "Ability Power", 0 }, - { new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), "Ability Power", 0 }, - { new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), "Ability Power", 0 }, - { new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), "Ability Power", 30 }, - { new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), "Ability Power", 0 }, - { new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), "Ability Power", 92 }, - { new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), "Attack Damage", 63 }, - { new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), "Attack Damage", 68 }, - { new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), "Attack Damage", 56 }, - { new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), "Attack Damage", 70 }, - { new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), "Attack Damage", 58 }, - { new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), "Attack Speed", 2 }, - { new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), "Attack Speed", 1 }, - { new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), "Attack Speed", 1 }, - { new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), "Attack Speed", 1 }, - { new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), "Attack Speed", 1 }, - { new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), "Attack Speed", 6 }, - { new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), "Health", 573 }, - { new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), "Health", 570 }, - { new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), "Health", 575 }, - { new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), "Health", 535 }, - { new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), "Health", 580 }, - { new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), "Health", 526 }, - { new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), "Mana", 278 }, - { new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), "Mana", 350 }, - { new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), "Mana", 200 }, - { new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), "Mana", 350 }, - { new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), "Mana", 0 }, - { new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), "Mana", 418 } - }); - - migrationBuilder.InsertData( - table: "Skills", - columns: new[] { "Name", "ChampionForeignKey", "Description", "Type" }, - values: new object[,] - { - { "Boule de feu", new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), "Fire!", 1 }, - { "White Star", new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), "Random damage", 3 } - }); - - migrationBuilder.InsertData( - table: "Skins", - columns: new[] { "Name", "ChampionForeignKey", "Description", "Icon", "ImageId", "Price" }, - values: new object[,] - { - { "Akali Infernale", new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), "Djinn qu'on invoque en dessous du monde, l'Infernale connue sous le nom d'Akali réduira en cendres les ennemis de son maître… mais le prix de son service est toujours exorbitant.", "empty", new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), 520f }, - { "Akshan Cyberpop", new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), "Les bas-fonds d'Audio City ont un nouveau héros : le Rebelle fluo. Cette position, Akshan la doit à son courage, sa sagesse et sa capacité à s'infiltrer dans des bâtiments d'affaires hautement sécurisés, et ce, sans être repéré. Son charme ravageur l'a aussi beaucoup aidé.", "empty", new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), 1350f } - }); - - migrationBuilder.CreateIndex( - name: "IX_CategoryRunes_RuneName", - table: "CategoryRunes", - column: "RuneName"); - - migrationBuilder.CreateIndex( - name: "IX_ChampionEntityRunePageEntity_RunePagesName", - table: "ChampionEntityRunePageEntity", - column: "RunePagesName"); - - migrationBuilder.CreateIndex( - name: "IX_Champions_ImageId", - table: "Champions", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_Characteristic_ChampionForeignKey", - table: "Characteristic", - column: "ChampionForeignKey"); - - migrationBuilder.CreateIndex( - name: "IX_Runes_ImageId", - table: "Runes", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_Skills_ChampionForeignKey", - table: "Skills", - column: "ChampionForeignKey"); - - migrationBuilder.CreateIndex( - name: "IX_Skins_ChampionForeignKey", - table: "Skins", - column: "ChampionForeignKey"); - - migrationBuilder.CreateIndex( - name: "IX_Skins_ImageId", - table: "Skins", - column: "ImageId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CategoryRunes"); - - migrationBuilder.DropTable( - name: "ChampionEntityRunePageEntity"); - - migrationBuilder.DropTable( - name: "Characteristic"); - - migrationBuilder.DropTable( - name: "Skills"); - - migrationBuilder.DropTable( - name: "Skins"); - - migrationBuilder.DropTable( - name: "Runes"); - - migrationBuilder.DropTable( - name: "RunePages"); - - migrationBuilder.DropTable( - name: "Champions"); - - migrationBuilder.DropTable( - name: "LargeImages"); - } - } -} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs deleted file mode 100644 index 3a1cbfe..0000000 --- a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs +++ /dev/null @@ -1,668 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using MyFlib; - -#nullable disable - -namespace MyFlib.Migrations -{ - [DbContext(typeof(LolDbContext))] - partial class LolDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("ChampionEntityRunePageEntity", b => - { - b.Property("ChampionsId") - .HasColumnType("TEXT"); - - b.Property("RunePagesName") - .HasColumnType("TEXT"); - - b.HasKey("ChampionsId", "RunePagesName"); - - b.HasIndex("RunePagesName"); - - b.ToTable("ChampionEntityRunePageEntity"); - }); - - modelBuilder.Entity("MyFlib.ChampionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("Bio") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.Property("Class") - .HasColumnType("INTEGER"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("Champions"); - - b.HasData( - new - { - Id = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Bio = "", - Class = 1, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Akali" - }, - new - { - Id = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Bio = "", - Class = 2, - Icon = "", - ImageId = new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), - Name = "Aatrox" - }, - new - { - Id = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Bio = "", - Class = 3, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Ahri" - }, - new - { - Id = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Bio = "", - Class = 4, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Akshan" - }, - new - { - Id = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Bio = "", - Class = 5, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Bard" - }, - new - { - Id = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Bio = "", - Class = 6, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Name = "Alistar" - }); - }); - - modelBuilder.Entity("MyFlib.DictionaryCategoryRune", b => - { - b.Property("RunePageName") - .HasColumnType("TEXT"); - - b.Property("RuneName") - .HasColumnType("TEXT"); - - b.Property("category") - .HasColumnType("INTEGER"); - - b.HasKey("RunePageName", "RuneName"); - - b.HasIndex("RuneName"); - - b.ToTable("CategoryRunes"); - - b.HasData( - new - { - RunePageName = "Page 1", - RuneName = "Hextech Flashtraption ", - category = 0 - }, - new - { - RunePageName = "Page 1", - RuneName = "Manaflow Band ", - category = 1 - }, - new - { - RunePageName = "Page 2", - RuneName = "Manaflow Band ", - category = 4 - }, - new - { - RunePageName = "Page 2", - RuneName = "Hextech Flashtraption ", - category = 5 - }); - }); - - modelBuilder.Entity("MyFlib.Entities.CharacteristicEntity", b => - { - b.Property("Name") - .HasMaxLength(254) - .HasColumnType("TEXT"); - - b.Property("ChampionForeignKey") - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("INTEGER"); - - b.HasKey("Name", "ChampionForeignKey"); - - b.HasIndex("ChampionForeignKey"); - - b.ToTable("Characteristic"); - - b.HasData( - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 58 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 92 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 6 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 526 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("ae5fe535-f041-445e-b570-28b75bc78cb9"), - Value = 418 - }, - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 68 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 0 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 1 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 570 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Value = 350 - }, - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 70 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 0 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 1 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 580 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("a4f84d92-c20f-4f2d-b3f9-ca00ef556e72"), - Value = 0 - }, - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 56 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 0 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 1 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 575 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Value = 200 - }, - new - { - Name = "Attack Damage", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 63 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 0 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 2 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 573 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("36ad2a82-d17b-47de-8a95-6e154a7df557"), - Value = 278 - }, - new - { - Name = "Ability Power", - ChampionForeignKey = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Value = 30 - }, - new - { - Name = "Attack Speed", - ChampionForeignKey = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Value = 1 - }, - new - { - Name = "Health", - ChampionForeignKey = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Value = 535 - }, - new - { - Name = "Mana", - ChampionForeignKey = new Guid("7f7746fa-b1cb-49da-9409-4b3e6910500e"), - Value = 350 - }); - }); - - modelBuilder.Entity("MyFlib.Entities.RunePageEntity", b => - { - b.Property("Name") - .HasMaxLength(64) - .HasColumnType("TEXT"); - - b.HasKey("Name"); - - b.ToTable("RunePages"); - - b.HasData( - new - { - Name = "Page 1" - }, - new - { - Name = "Page 2" - }); - }); - - modelBuilder.Entity("MyFlib.LargeImageEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("Base64") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("LargeImages"); - - b.HasData( - new - { - Id = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Base64 = "empty" - }, - new - { - Id = new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), - Base64 = " " - }); - }); - - modelBuilder.Entity("MyFlib.RuneEntity", b => - { - b.Property("Name") - .HasMaxLength(64) - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("Family") - .HasColumnType("INTEGER"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("TEXT"); - - b.HasKey("Name"); - - b.HasIndex("ImageId"); - - b.ToTable("Runes"); - - b.HasData( - new - { - Name = "Hextech Flashtraption ", - Description = "While Flash is on cooldown, it is replaced by Hexflash.", - Family = 0, - Icon = "", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65") - }, - new - { - Name = "Manaflow Band ", - Description = "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", - Family = 2, - Icon = "", - ImageId = new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c") - }); - }); - - modelBuilder.Entity("MyFlib.SkillEntity", b => - { - b.Property("Name") - .HasMaxLength(64) - .HasColumnType("TEXT"); - - b.Property("ChampionForeignKey") - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("Name"); - - b.HasIndex("ChampionForeignKey"); - - b.ToTable("Skills"); - - b.HasData( - new - { - Name = "Boule de feu", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Description = "Fire!", - Type = 1 - }, - new - { - Name = "White Star", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Description = "Random damage", - Type = 3 - }); - }); - - modelBuilder.Entity("MyFlib.SkinEntity", b => - { - b.Property("Name") - .HasMaxLength(254) - .HasColumnType("TEXT"); - - b.Property("ChampionForeignKey") - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(1000) - .HasColumnType("TEXT"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ImageId") - .HasColumnType("TEXT"); - - b.Property("Price") - .HasColumnType("REAL"); - - b.HasKey("Name"); - - b.HasIndex("ChampionForeignKey"); - - b.HasIndex("ImageId"); - - b.ToTable("Skins"); - - b.HasData( - new - { - Name = "Akali Infernale", - ChampionForeignKey = new Guid("4422c524-b2cb-43ef-8263-990c3cea7cae"), - Description = "Djinn qu'on invoque en dessous du monde, l'Infernale connue sous le nom d'Akali réduira en cendres les ennemis de son maître… mais le prix de son service est toujours exorbitant.", - Icon = "empty", - ImageId = new Guid("8d121cdc-6787-4738-8edd-9e026ac16b65"), - Price = 520f - }, - new - { - Name = "Akshan Cyberpop", - ChampionForeignKey = new Guid("3708dcfd-02a1-491e-b4f7-e75bf274cf23"), - Description = "Les bas-fonds d'Audio City ont un nouveau héros : le Rebelle fluo. Cette position, Akshan la doit à son courage, sa sagesse et sa capacité à s'infiltrer dans des bâtiments d'affaires hautement sécurisés, et ce, sans être repéré. Son charme ravageur l'a aussi beaucoup aidé.", - Icon = "empty", - ImageId = new Guid("9f9086f5-5cc5-47b5-af9b-a935f4e9b89c"), - Price = 1350f - }); - }); - - modelBuilder.Entity("ChampionEntityRunePageEntity", b => - { - b.HasOne("MyFlib.ChampionEntity", null) - .WithMany() - .HasForeignKey("ChampionsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MyFlib.Entities.RunePageEntity", null) - .WithMany() - .HasForeignKey("RunePagesName") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("MyFlib.ChampionEntity", b => - { - b.HasOne("MyFlib.LargeImageEntity", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("MyFlib.DictionaryCategoryRune", b => - { - b.HasOne("MyFlib.RuneEntity", "rune") - .WithMany("DictionaryCategoryRunes") - .HasForeignKey("RuneName") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MyFlib.Entities.RunePageEntity", "runePage") - .WithMany("DictionaryCategoryRunes") - .HasForeignKey("RunePageName") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("rune"); - - b.Navigation("runePage"); - }); - - modelBuilder.Entity("MyFlib.Entities.CharacteristicEntity", b => - { - b.HasOne("MyFlib.ChampionEntity", "Champion") - .WithMany("Characteristics") - .HasForeignKey("ChampionForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Champion"); - }); - - modelBuilder.Entity("MyFlib.RuneEntity", b => - { - b.HasOne("MyFlib.LargeImageEntity", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("MyFlib.SkillEntity", b => - { - b.HasOne("MyFlib.ChampionEntity", "Champion") - .WithMany("Skills") - .HasForeignKey("ChampionForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Champion"); - }); - - modelBuilder.Entity("MyFlib.SkinEntity", b => - { - b.HasOne("MyFlib.ChampionEntity", "Champion") - .WithMany("Skins") - .HasForeignKey("ChampionForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MyFlib.LargeImageEntity", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Champion"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("MyFlib.ChampionEntity", b => - { - b.Navigation("Characteristics"); - - b.Navigation("Skills"); - - b.Navigation("Skins"); - }); - - modelBuilder.Entity("MyFlib.Entities.RunePageEntity", b => - { - b.Navigation("DictionaryCategoryRunes"); - }); - - modelBuilder.Entity("MyFlib.RuneEntity", b => - { - b.Navigation("DictionaryCategoryRunes"); - }); -#pragma warning restore 612, 618 - } - } -}