diff --git a/Sources/API_LoL/API_LoL.csproj b/Sources/API_LoL/API_LoL.csproj
index a8c4de7..db2c1c8 100644
--- a/Sources/API_LoL/API_LoL.csproj
+++ b/Sources/API_LoL/API_LoL.csproj
@@ -17,6 +17,7 @@
+
diff --git a/Sources/API_LoL/Controllers/ChampionsController.cs b/Sources/API_LoL/Controllers/ChampionsController.cs
index 1b2b021..96adf52 100644
--- a/Sources/API_LoL/Controllers/ChampionsController.cs
+++ b/Sources/API_LoL/Controllers/ChampionsController.cs
@@ -30,6 +30,12 @@ namespace API_LoL.Controllers
// GET api//5
+ [HttpGet("count")]
+ public async Task GetCount()
+ {
+ return Ok(ChampionsManager.GetNbItems());
+ }
+
[HttpGet]
public async Task Get(string? name = null,String? skill = null, String? characteristic = null,int index = 0,int size =10)
{
@@ -92,9 +98,10 @@ namespace API_LoL.Controllers
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
if (list.Count() == 1)
{
- var skins = await SkinsManager.GetItemsByChampion(list.First(), 0, await SkinsManager.GetNbItemsByChampion(list.First()));
- if (skins.Count() != 0)
+ var nb = await SkinsManager.GetNbItemsByChampion(list.First());
+ if (nb != 0)
{
+ var skins = await SkinsManager.GetItemsByChampion(list.First(), 0, nb);
return Ok(skins.Select(skin => skin?.ToDTO()));
}
else { return NoContent(); }
@@ -102,8 +109,27 @@ namespace API_LoL.Controllers
else { return NoContent(); }
}
- // POST api/
- [HttpPost]
+ //[HttpGet("name/skills")]
+ //public async Task GetSkillsByName(String name)
+ //{
+ // if (string.IsNullOrEmpty(name)) return BadRequest();
+ // var list = await ChampionsManager.GetItemsByName(name, 0, 1);
+ // if (list.Count() == 1)
+ // {
+ // var skins = await SkinsManager.GetItemsByChampion(list.First(), 0, await SkinsManager.GetNbItemsByChampion(list.First()));
+ // if (skins.Count() != 0)
+ // {
+ // return Ok(skins.Select(skin => skin?.ToDTO()));
+ // }
+ // else { return NoContent(); }
+ // }
+ // else { return NoContent(); }
+ //}
+
+
+
+ // POST api/
+ [HttpPost]
public async Task Post(ChampionDTO champion)
{
if (champion == null)
@@ -112,21 +138,43 @@ namespace API_LoL.Controllers
}
else
{
+ var champ = await ChampionsManager.GetItemsByName(champion.Name, 0, 1);
+ if(champ.Count() != 0 && champ.FirstOrDefault().Name == champion.Name)
+ {
+ return Conflict(champion);
+ }
await ChampionsManager.AddItem(champion.ToChampion());
return CreatedAtAction("Post",champion);
+
}
}
// PUT api//5
- [HttpPut("{id}")]
- public void Put(int id, [FromBody] string value)
+ [HttpPut("name")]
+ public async Task Put(string name, ChampionDTO championDTO)
{
+ if(string.IsNullOrEmpty(name))
+ return BadRequest();
+ if(championDTO == null)
+ return UnprocessableEntity();
+ var list = await ChampionsManager.GetItemsByName(name, 0, 1);
+ if (list.Count() == 1)
+ {
+ return Ok(ChampionsManager.UpdateItem(list.First(), championDTO.ToChampion()));
+ }
+ else { return NoContent(); }
}
// DELETE api//5
- [HttpDelete("{id}")]
- public void Delete(int id)
+ [HttpDelete("name")]
+ public async Task Delete(string name)
{
+ if (string.IsNullOrEmpty(name))
+ return BadRequest();
+ var list = await ChampionsManager.GetItemsByName(name, 0, 1);
+ if(list.Count() == 1){
+ return Ok(await ChampionsManager.DeleteItem(list.First()));
+ }else { return NoContent(); }
}
}
}
diff --git a/Sources/API_LoL/Mapper/ChampionMapper.cs b/Sources/API_LoL/Mapper/ChampionMapper.cs
index 3dd6a11..632149e 100644
--- a/Sources/API_LoL/Mapper/ChampionMapper.cs
+++ b/Sources/API_LoL/Mapper/ChampionMapper.cs
@@ -12,19 +12,13 @@ namespace DTO.Mapper
{
public static ChampionDTO ToDTO(this Champion champion)
{
- return new ChampionDTO(champion.Name, champion.Bio, champion.Icon,champion.Class.ToDTO().ToString());
- //return new ChampionDTO(champion.Name, champion.Bio, champion.Icon, champion.Skills);
+ return new ChampionDTO(champion.Name, champion.Bio, champion.Icon, champion.Class.ToDTO(), champion.Image.Base64);
}
public static Champion ToChampion(this ChampionDTO champion)
{
- Champion champ = new Champion(champion.Name, champion.Class.ToChampionClass(), champion.Icon, "", champion.Bio);
+ return new Champion(champion.Name, champClass: champion.Class.ToChampionClass(),icon: champion.Icon,bio: champion.Bio,image :champion.Image);
- //foreach (Skill skill in champion.Skills)
- //{
- // champ.AddSkill(skill);
- //}
- return champ;
}
}
}
diff --git a/Sources/API_LoL/Mapper/SkinMapper.cs b/Sources/API_LoL/Mapper/SkinMapper.cs
index 25ac8f6..5b18c55 100644
--- a/Sources/API_LoL/Mapper/SkinMapper.cs
+++ b/Sources/API_LoL/Mapper/SkinMapper.cs
@@ -7,12 +7,12 @@ namespace API_LoL.Mapper
{
public static SkinDTO ToDTO(this Skin skin)
{
- return new SkinDTO(skin.Name, skin.Description, skin.Icon);
+ return new SkinDTO(skin.Name, skin.Description, skin.Icon,skin.Image.Base64,skin.Price);
}
public static Skin ToSkin(this SkinDTO skin)
{
- return new Skin(skin.Name, null, icon:skin.Icon) ;
+ return new Skin(skin.Name, null,price: skin.Price, icon:skin.Icon,image: skin.Image,description: skin.Description) ;
}
}
}
diff --git a/Sources/API_LoL/Program.cs b/Sources/API_LoL/Program.cs
index c192eac..f1b44d0 100644
--- a/Sources/API_LoL/Program.cs
+++ b/Sources/API_LoL/Program.cs
@@ -1,4 +1,6 @@
using API_LoL;
+using EntityFramework;
+using EntityFramework.Manager;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Versioning;
using Model;
@@ -11,7 +13,7 @@ var builder = WebApplication.CreateBuilder(args);
///NOT WORKING WHEN CHANGING VERSIONS :
/// voir sur https://blog.christian-schou.dk/how-to-use-api-versioning-in-net-core-web-api/ rubrique "Configure SwaggerOptions"
-/// (mais requiere l'injection de dépendance).
+/// (mais requiere l'injection de d�pendance).
/// Sinon, code plus simple disponible par le prof
@@ -37,13 +39,24 @@ builder.Services.AddControllers();
-builder.Services.AddScoped();
+//builder.Services.AddScoped();
+builder.Services.AddHttpClient();
+//builder.Services.AddScoped();
+builder.Services.AddScoped();
+
+builder.Services.AddDbContext();
var app = builder.Build();
+using(var scope = app.Services.CreateScope())
+{
+ var context = scope.ServiceProvider.GetService();
+ context.Database.EnsureCreated();
+}
+
var apiVersionDescriptionProvider = app.Services.GetRequiredService();
diff --git a/Sources/API_LoL/champion.db b/Sources/API_LoL/champion.db
new file mode 100644
index 0000000..cfdeed2
Binary files /dev/null and b/Sources/API_LoL/champion.db differ
diff --git a/Sources/Api_UT/ChampionControllerTest.cs b/Sources/Api_UT/ChampionControllerTest.cs
index a3ca675..09c7875 100644
--- a/Sources/Api_UT/ChampionControllerTest.cs
+++ b/Sources/Api_UT/ChampionControllerTest.cs
@@ -21,7 +21,7 @@ namespace Api_UT
public async Task Get_Default_OkList()
{
- List list = new List {new ChampionDTO("Akali","","","Assassin"), new ChampionDTO("Aatrox", "", "", "Fighter"), new ChampionDTO("Ahri", "", "", "Mage"), new ChampionDTO("Akshan", "", "", "Marksman"), new ChampionDTO("Bard", "", "","Support"), new ChampionDTO("Alistar", "", "","Tank") };
+ List list = new List {new ChampionDTO("Akali","","","Assassin",""), new ChampionDTO("Aatrox", "", "", "Fighter",""), new ChampionDTO("Ahri", "", "", "Mage",""), new ChampionDTO("Akshan", "", "", "Marksman",""), new ChampionDTO("Bard", "", "","Support",""), new ChampionDTO("Alistar", "", "","Tank","") };
IActionResult a = await api.Get();
a.Should().NotBeNull();
var aObject = a as OkObjectResult;
@@ -42,7 +42,7 @@ namespace Api_UT
[TestMethod]
public async Task Get_2First_OkListOf2()
{
- List list = new List { new ChampionDTO("Akali", "", "", "Assassin"), new ChampionDTO("Aatrox", "", "", "Fighter") };
+ List list = new List { new ChampionDTO("Akali", "", "", "Assassin",""), new ChampionDTO("Aatrox", "", "", "Fighter","") };
IActionResult a = await api.Get(index: 0,size: 2);
@@ -57,7 +57,7 @@ namespace Api_UT
[TestMethod]
public async Task Get_FilterAName_OkListOf5()
{
- List list = new List { new ChampionDTO("Akali", "", "", "Assassin"), new ChampionDTO("Akshan", "", "", "Marksman") };
+ List list = new List { new ChampionDTO("Akali", "", "", "Assassin", ""), new ChampionDTO("Akshan", "", "", "Marksman", "") };
IActionResult a = await api.Get(name: "Ak");
@@ -75,10 +75,12 @@ namespace Api_UT
public async Task Post_ValidChampion_Created()
{
ChampionsController api = new ChampionsController(new StubData());
- IActionResult a = await api.Post(new ChampionDTO("nom","bio","icon", "Assassin"));
+ IActionResult a = await api.Post(new ChampionDTO("nom","bio","icon", "Assassin",""));
+ var action = (CreatedAtActionResult)a;
+ var champAction = action.Value as IEnumerable;
Assert.IsNotNull(a);
- ChampionDTO champ = new ChampionDTO("nom", "bio", "icon","Assassin");
- Assert.IsTrue(champ.equals((ChampionDTO)((CreatedAtActionResult)a).Value));
+ ChampionDTO champ = new ChampionDTO("nom", "bio", "icon","Assassin", "");
+ Assert.IsTrue(champ.equals(other: (ChampionDTO)((CreatedAtActionResult)a).Value));
}
}
diff --git a/Sources/DTO/ChampionDTO.cs b/Sources/DTO/ChampionDTO.cs
index 723d7b4..23478dd 100644
--- a/Sources/DTO/ChampionDTO.cs
+++ b/Sources/DTO/ChampionDTO.cs
@@ -5,17 +5,19 @@ namespace DTO
{
public class ChampionDTO
{
- public ChampionDTO(string name, string bio, string icon, string championClassDTO)
+ public ChampionDTO(string name, string bio, string icon, string Class, string image)
{
Name = name;
Bio = bio;
Icon = icon;
- Class = championClassDTO;
+ this.Class = Class;
+ Image = image;
}
public string Name { get; set; }
public string Bio { get; set; }
public string Icon { get; set; }
+ public string Image { get; set; }
public string Class { get; set; }
public bool equals(ChampionDTO other)
diff --git a/Sources/DTO/SkinDTO.cs b/Sources/DTO/SkinDTO.cs
index 32696d6..eb255f6 100644
--- a/Sources/DTO/SkinDTO.cs
+++ b/Sources/DTO/SkinDTO.cs
@@ -13,10 +13,16 @@ namespace DTO
public string Description { get; set; }
public string Icon { get; set; }
- public SkinDTO(string name,string description,string icon) {
+ public string Image { get; set; }
+
+ public float Price { get; set; }
+
+ public SkinDTO(string name,string description,string icon,string image,float price) {
this.Name = name;
this.Description = description;
this.Icon = icon;
+ this.Image = image;
+ this.Price = price;
}
}
diff --git a/Sources/EF_UT/EFDataManagerChampionTest.cs b/Sources/EF_UT/EFDataManagerChampionTest.cs
new file mode 100644
index 0000000..07e3ca2
--- /dev/null
+++ b/Sources/EF_UT/EFDataManagerChampionTest.cs
@@ -0,0 +1,53 @@
+using EntityFramework;
+using EntityFramework.Manager;
+using FluentAssertions;
+using FluentAssertions.Primitives;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.DependencyInjection;
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EF_UT
+{
+ [TestClass]
+ public class EFDataManagerChampionTest
+ {
+ [TestMethod]
+ public void Add_ValidChampion_Added()
+ {
+ IDataManager dataManager = new EFDataManager();
+ IChampionsManager championsManager = dataManager.ChampionsMgr;
+
+ var champ = championsManager.AddItem(new Champion("test"));
+ }
+
+ [TestMethod]
+ public async Task GetItemsByName_DefaultChamp_One()
+ {
+ var builder = WebApplication.CreateBuilder();
+
+ builder.Services.AddDbContext();
+
+ var app = builder.Build();
+
+ using (var scope = app.Services.CreateScope())
+ {
+ var context = scope.ServiceProvider.GetService();
+ context.Database.EnsureCreated();
+ }
+
+ IDataManager dataManager = new EFDataManager();
+ IChampionsManager championsManager = dataManager.ChampionsMgr;
+
+ var ak = (await championsManager.GetItemsByName("A", 0, 1)).First();
+
+ Assert.IsNotNull(ak);
+ //Assert.AreEqual("Akali", ak.Name);
+ }
+ }
+}
diff --git a/Sources/EntityFramework/EntityFramework.csproj b/Sources/EntityFramework/EntityFramework.csproj
index 2d1f7fc..358fe36 100644
--- a/Sources/EntityFramework/EntityFramework.csproj
+++ b/Sources/EntityFramework/EntityFramework.csproj
@@ -1,4 +1,4 @@
-
+
Exe
@@ -8,6 +8,14 @@
$(MSBuildProjectDirectory)
+
+
+
+
+
+
+
+
@@ -18,6 +26,7 @@
+
diff --git a/Sources/EntityFramework/LoLDbContext.cs b/Sources/EntityFramework/LoLDbContext.cs
index 6812e57..042b646 100644
--- a/Sources/EntityFramework/LoLDbContext.cs
+++ b/Sources/EntityFramework/LoLDbContext.cs
@@ -39,7 +39,7 @@ namespace EntityFramework
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity().HasKey(entity => entity.Name);
- modelBuilder.Entity().ToTable("Champion");
+ modelBuilder.Entity().ToTable("Champions");
//modelBuilder.Entity().Property(entity => entity.Id)
// .ValueGeneratedOnAdd();
diff --git a/Sources/EntityFramework/Manager/EFDataManager.Champions.cs b/Sources/EntityFramework/Manager/EFDataManager.Champions.cs
new file mode 100644
index 0000000..689959b
--- /dev/null
+++ b/Sources/EntityFramework/Manager/EFDataManager.Champions.cs
@@ -0,0 +1,186 @@
+using EntityFramework.Mapper;
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+namespace EntityFramework.Manager
+{
+ public partial class EFDataManager
+ {
+ public class ChampionsManager : IChampionsManager
+ {
+ private readonly EFDataManager parent;
+
+ public ChampionsManager(EFDataManager parent)
+ {
+ this.parent = parent;
+ }
+
+ public async Task AddItem(Champion? item)
+ {
+ using(var context = new LoLDBContextWithStub())
+ {
+ if (item != null)
+ {
+
+ context.Add(item.ToEntity());
+ context.SaveChanges();
+ return item;
+ }
+ else
+ {
+ throw new Exception();
+ }
+ }
+ }
+
+ public async Task DeleteItem(Champion? item)
+ {
+ using (var context = new LoLDBContextWithStub())
+ {
+ var champ = context.Champions.Select(c => c == item.ToEntity());
+
+ if(champ.Count()<1)
+ {
+ return false;
+ }
+ context.Champions.Remove(item.ToEntity());
+ context.SaveChanges();
+ return true;
+
+ }
+ }
+
+ public async Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ using(var context = new LoLDBContextWithStub() )
+ {
+ var champ = context.Champions.ToArray();
+ if (descending == false)
+ {
+ return champ.ToList().Skip(index * count).Take(count).Select(c => c.ToChampion()).OrderBy(c => c.Name);
+ }
+ else
+ {
+ return champ.ToList().Skip(index * count).Take(count).Select(c => c.ToChampion()).OrderByDescending(c => c.Name);
+ }
+ }
+ }
+
+ public Task> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetItemsByClass(Model.ChampionClass championClass, 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)
+ {
+ using (var context = new LoLDBContextWithStub())
+ {
+ var champ = context.Champions.Where(c => c.Name.Contains(substring)).AsEnumerable();
+ if (descending == false)
+ {
+ return champ.Select(c => c.ToChampion()).ToList().Skip(index * count).Take(count).OrderBy(c=> c.Name);
+
+ }
+ else
+ {
+ return champ.Select(c => c.ToChampion()).ToList().Skip(index*count).Take(count).OrderByDescending(c => c.Name);
+
+ }
+
+
+
+ }
+ }
+
+ public Task> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ using(var context = new LoLDBContextWithStub())
+ {
+ var champ = context.Champions.Where(c => c.Skills.Any(c => c.Name.Contains(skill)));
+ if (descending.Equals(false))
+ {
+ return champ.Select(c=> c.ToChampion()).ToList().Skip(index * count).Take(count).OrderBy(c => c.Name);
+
+ }
+ else
+ {
+ return champ.Select(c => c.ToChampion()).ToList().Skip(index * count).Take(count).OrderByDescending(c => c.Name);
+ }
+ }
+ }
+
+ public async Task GetNbItems()
+ {
+ using(var context = new LoLDBContextWithStub())
+ {
+ return context.Champions.Count();
+ }
+ }
+
+ public Task GetNbItemsByCharacteristic(string charName)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsByClass(Model.ChampionClass championClass)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsByName(string substring)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsByRunePage(RunePage? runePage)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsBySkill(Skill? skill)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsBySkill(string skill)
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task UpdateItem(Champion? oldItem, Champion? newItem)
+ {
+ using(var context = new LoLDBContextWithStub())
+ {
+ if (oldItem != null && newItem != null)
+ {
+ var champ = context.Champions.Where(c => c == oldItem.ToEntity()).First();
+ champ = newItem.ToEntity();
+ context.SaveChanges();
+ return newItem;
+ }
+ else { throw new Exception(); }
+ }
+ }
+ }
+ }
+}
diff --git a/Sources/EntityFramework/Manager/EFDataManager.Skins.cs b/Sources/EntityFramework/Manager/EFDataManager.Skins.cs
new file mode 100644
index 0000000..bed5678
--- /dev/null
+++ b/Sources/EntityFramework/Manager/EFDataManager.Skins.cs
@@ -0,0 +1,85 @@
+using EntityFramework.Mapper;
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework.Manager
+{
+ public partial class EFDataManager
+ {
+ public class SkinsManager : ISkinsManager
+ {
+ private readonly EFDataManager parent;
+
+ public SkinsManager(EFDataManager parent)
+ {
+ this.parent = parent;
+ }
+
+ public Task AddItem(Skin? item)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task DeleteItem(Skin? item)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ using (var context = new LoLDBContextWithStub())
+ {
+ var skins = context.Skins.Where(c => c.Champion.Equals(champion)).ToList();
+
+ if (descending == false)
+ {
+ return skins.Select(c => c.ToSkin()).ToList().Skip(index * count).Take(count).OrderBy(c => c.Name);
+
+ }
+ else
+ {
+ return skins.Select(c => c.ToSkin()).ToList().Skip(index * count).Take(count).OrderByDescending(c => c.Name);
+
+ }
+ }
+ }
+
+ public Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItems()
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task GetNbItemsByChampion(Champion? champion)
+ {
+ using(var context = new LoLDBContextWithStub())
+ {
+ return context.Skins.Where(c => c.Champion.Equals(champion.ToEntity())).Count();
+ }
+ }
+
+ public Task GetNbItemsByName(string substring)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task UpdateItem(Skin? oldItem, Skin? newItem)
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/Sources/EntityFramework/Manager/EFDataManager.cs b/Sources/EntityFramework/Manager/EFDataManager.cs
new file mode 100644
index 0000000..5c5d677
--- /dev/null
+++ b/Sources/EntityFramework/Manager/EFDataManager.cs
@@ -0,0 +1,25 @@
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework.Manager
+{
+ public partial class EFDataManager : IDataManager
+ {
+ public EFDataManager() {
+ ChampionsMgr = new ChampionsManager(this);
+ SkinsMgr = new SkinsManager(this);
+ }
+ public IChampionsManager ChampionsMgr { get; }
+
+ public ISkinsManager SkinsMgr { get; }
+
+ public IRunesManager RunesMgr { get; }
+
+ public IRunePagesManager RunePagesMgr { get; }
+
+ }
+}
diff --git a/Sources/EntityFramework/Mapper/ChampionMapper.cs b/Sources/EntityFramework/Mapper/ChampionMapper.cs
index 14942d1..da146b2 100644
--- a/Sources/EntityFramework/Mapper/ChampionMapper.cs
+++ b/Sources/EntityFramework/Mapper/ChampionMapper.cs
@@ -12,5 +12,11 @@ namespace EntityFramework.Mapper
public static ChampionEntity ToEntity(this Champion champion) {
return new ChampionEntity { Name = champion.Name, Bio = champion.Bio, Icon = champion.Icon };
}
+
+ public static Champion ToChampion(this ChampionEntity champion)
+ {
+ return new Champion(champion.Name,bio: champion.Bio,icon: champion.Icon);
+ }
+
}
}
diff --git a/Sources/EntityFramework/Mapper/SkinMapper.cs b/Sources/EntityFramework/Mapper/SkinMapper.cs
new file mode 100644
index 0000000..3ce09ff
--- /dev/null
+++ b/Sources/EntityFramework/Mapper/SkinMapper.cs
@@ -0,0 +1,24 @@
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework.Mapper
+{
+ public static class SkinMapper
+ {
+ public static SkinEntity ToEntity(this Skin skin)
+ {
+ return new SkinEntity { Champion = skin.Champion.ToEntity(), Description = skin.Description, Icon = skin.Icon, Image = skin.Image.Base64, Name = skin.Name, Price = skin.Price };
+ }
+
+ public static Skin ToSkin(this SkinEntity entity)
+ {
+ return new Skin(entity.Name,entity.Champion.ToChampion(),price: entity.Price,icon: entity.Icon, image: entity.Image,description: entity.Description);
+ }
+
+
+ }
+}
diff --git a/Sources/EntityFramework/Migrations/20230323203441_manymanymig.Designer.cs b/Sources/EntityFramework/Migrations/20230323203441_manymanymig.Designer.cs
deleted file mode 100644
index f36cc78..0000000
--- a/Sources/EntityFramework/Migrations/20230323203441_manymanymig.Designer.cs
+++ /dev/null
@@ -1,201 +0,0 @@
-//
-using EntityFramework;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EntityFramework.Migrations
-{
- [DbContext(typeof(LoLDbContext))]
- [Migration("20230323203441_manymanymig")]
- partial class manymanymig
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
-
- modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
- {
- b.Property("ChampionName")
- .HasColumnType("TEXT");
-
- b.Property("RunePageEntitiesName")
- .HasColumnType("TEXT");
-
- b.HasKey("ChampionName", "RunePageEntitiesName");
-
- b.HasIndex("RunePageEntitiesName");
-
- b.ToTable("ChampionEntityRunePageEntity");
- });
-
- modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
- {
- b.Property("Name")
- .HasMaxLength(50)
- .HasColumnType("TEXT");
-
- b.Property("Bio")
- .IsRequired()
- .HasMaxLength(500)
- .HasColumnType("string")
- .HasColumnName("Bio");
-
- b.Property("Icon")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Image")
- .HasColumnType("TEXT");
-
- b.HasKey("Name");
-
- b.ToTable("Champion", (string)null);
- });
-
- modelBuilder.Entity("EntityFramework.LargeImageEntity", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Base64")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Image");
- });
-
- modelBuilder.Entity("EntityFramework.RuneEntity", b =>
- {
- b.Property("Name")
- .HasColumnType("TEXT");
-
- b.HasKey("Name");
-
- b.ToTable("Rune");
- });
-
- modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
- {
- b.Property("Name")
- .HasColumnType("TEXT");
-
- b.Property("RuneName")
- .HasColumnType("TEXT");
-
- b.HasKey("Name");
-
- b.HasIndex("RuneName");
-
- b.ToTable("RunePage", (string)null);
- });
-
- modelBuilder.Entity("EntityFramework.SkillEntity", b =>
- {
- b.Property("Name")
- .HasColumnType("TEXT");
-
- b.Property("ChampionEntityName")
- .HasColumnType("TEXT");
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Type")
- .HasColumnType("INTEGER");
-
- b.HasKey("Name");
-
- b.HasIndex("ChampionEntityName");
-
- b.ToTable("SkillEntity");
- });
-
- modelBuilder.Entity("EntityFramework.SkinEntity", b =>
- {
- b.Property("Name")
- .ValueGeneratedOnAdd()
- .HasColumnType("TEXT");
-
- b.Property("ChampionEntityForeignKey")
- .HasColumnType("TEXT");
-
- b.Property("Description")
- .HasColumnType("TEXT");
-
- b.Property("Icon")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Image")
- .HasColumnType("TEXT");
-
- b.Property("Price")
- .HasColumnType("REAL");
-
- b.HasKey("Name");
-
- b.HasIndex("ChampionEntityForeignKey");
-
- b.ToTable("Skins");
- });
-
- modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
- {
- b.HasOne("EntityFramework.ChampionEntity", null)
- .WithMany()
- .HasForeignKey("ChampionName")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("EntityFramework.RunePageEntity", null)
- .WithMany()
- .HasForeignKey("RunePageEntitiesName")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
- {
- b.HasOne("EntityFramework.RuneEntity", "Rune")
- .WithMany()
- .HasForeignKey("RuneName");
-
- b.Navigation("Rune");
- });
-
- modelBuilder.Entity("EntityFramework.SkillEntity", b =>
- {
- b.HasOne("EntityFramework.ChampionEntity", null)
- .WithMany("Skills")
- .HasForeignKey("ChampionEntityName");
- });
-
- modelBuilder.Entity("EntityFramework.SkinEntity", b =>
- {
- b.HasOne("EntityFramework.ChampionEntity", "Champion")
- .WithMany("skins")
- .HasForeignKey("ChampionEntityForeignKey");
-
- b.Navigation("Champion");
- });
-
- modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
- {
- b.Navigation("Skills");
-
- b.Navigation("skins");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Sources/EntityFramework/Migrations/20230323203441_manymanymig.cs b/Sources/EntityFramework/Migrations/20230323203441_manymanymig.cs
deleted file mode 100644
index 3908652..0000000
--- a/Sources/EntityFramework/Migrations/20230323203441_manymanymig.cs
+++ /dev/null
@@ -1,178 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace EntityFramework.Migrations
-{
- ///
- public partial class manymanymig : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Champion",
- columns: table => new
- {
- Name = table.Column(type: "TEXT", maxLength: 50, nullable: false),
- Bio = table.Column(type: "string", maxLength: 500, nullable: false),
- Icon = table.Column(type: "TEXT", nullable: false),
- Image = table.Column(type: "TEXT", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Champion", x => x.Name);
- });
-
- migrationBuilder.CreateTable(
- name: "Image",
- columns: table => new
- {
- Id = table.Column(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- Base64 = table.Column(type: "TEXT", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Image", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Rune",
- columns: table => new
- {
- Name = table.Column(type: "TEXT", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Rune", x => x.Name);
- });
-
- migrationBuilder.CreateTable(
- name: "SkillEntity",
- columns: table => new
- {
- Name = table.Column(type: "TEXT", nullable: false),
- Type = table.Column(type: "INTEGER", nullable: false),
- Description = table.Column(type: "TEXT", nullable: false),
- ChampionEntityName = table.Column(type: "TEXT", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_SkillEntity", x => x.Name);
- table.ForeignKey(
- name: "FK_SkillEntity_Champion_ChampionEntityName",
- column: x => x.ChampionEntityName,
- principalTable: "Champion",
- principalColumn: "Name");
- });
-
- migrationBuilder.CreateTable(
- name: "Skins",
- columns: table => new
- {
- Name = table.Column(type: "TEXT", nullable: false),
- Description = table.Column(type: "TEXT", nullable: true),
- Icon = table.Column(type: "TEXT", nullable: false),
- Image = table.Column(type: "TEXT", nullable: true),
- Price = table.Column(type: "REAL", nullable: false),
- ChampionEntityForeignKey = table.Column(type: "TEXT", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Skins", x => x.Name);
- table.ForeignKey(
- name: "FK_Skins_Champion_ChampionEntityForeignKey",
- column: x => x.ChampionEntityForeignKey,
- principalTable: "Champion",
- principalColumn: "Name");
- });
-
- migrationBuilder.CreateTable(
- name: "RunePage",
- columns: table => new
- {
- Name = table.Column(type: "TEXT", nullable: false),
- RuneName = table.Column(type: "TEXT", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_RunePage", x => x.Name);
- table.ForeignKey(
- name: "FK_RunePage_Rune_RuneName",
- column: x => x.RuneName,
- principalTable: "Rune",
- principalColumn: "Name");
- });
-
- migrationBuilder.CreateTable(
- name: "ChampionEntityRunePageEntity",
- columns: table => new
- {
- ChampionName = table.Column(type: "TEXT", nullable: false),
- RunePageEntitiesName = table.Column(type: "TEXT", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ChampionEntityRunePageEntity", x => new { x.ChampionName, x.RunePageEntitiesName });
- table.ForeignKey(
- name: "FK_ChampionEntityRunePageEntity_Champion_ChampionName",
- column: x => x.ChampionName,
- principalTable: "Champion",
- principalColumn: "Name",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_ChampionEntityRunePageEntity_RunePage_RunePageEntitiesName",
- column: x => x.RunePageEntitiesName,
- principalTable: "RunePage",
- principalColumn: "Name",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_ChampionEntityRunePageEntity_RunePageEntitiesName",
- table: "ChampionEntityRunePageEntity",
- column: "RunePageEntitiesName");
-
- migrationBuilder.CreateIndex(
- name: "IX_RunePage_RuneName",
- table: "RunePage",
- column: "RuneName");
-
- migrationBuilder.CreateIndex(
- name: "IX_SkillEntity_ChampionEntityName",
- table: "SkillEntity",
- column: "ChampionEntityName");
-
- migrationBuilder.CreateIndex(
- name: "IX_Skins_ChampionEntityForeignKey",
- table: "Skins",
- column: "ChampionEntityForeignKey");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "ChampionEntityRunePageEntity");
-
- migrationBuilder.DropTable(
- name: "Image");
-
- migrationBuilder.DropTable(
- name: "SkillEntity");
-
- migrationBuilder.DropTable(
- name: "Skins");
-
- migrationBuilder.DropTable(
- name: "RunePage");
-
- migrationBuilder.DropTable(
- name: "Champion");
-
- migrationBuilder.DropTable(
- name: "Rune");
- }
- }
-}
diff --git a/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs b/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
deleted file mode 100644
index e65f6fe..0000000
--- a/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-//
-using EntityFramework;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EntityFramework.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("ChampionName")
- .HasColumnType("TEXT");
-
- b.Property("RunePageEntitiesName")
- .HasColumnType("TEXT");
-
- b.HasKey("ChampionName", "RunePageEntitiesName");
-
- b.HasIndex("RunePageEntitiesName");
-
- b.ToTable("ChampionEntityRunePageEntity");
- });
-
- modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
- {
- b.Property("Name")
- .HasMaxLength(50)
- .HasColumnType("TEXT");
-
- b.Property("Bio")
- .IsRequired()
- .HasMaxLength(500)
- .HasColumnType("string")
- .HasColumnName("Bio");
-
- b.Property("Icon")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Image")
- .HasColumnType("TEXT");
-
- b.HasKey("Name");
-
- b.ToTable("Champion", (string)null);
- });
-
- modelBuilder.Entity("EntityFramework.LargeImageEntity", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Base64")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Image");
- });
-
- modelBuilder.Entity("EntityFramework.RuneEntity", b =>
- {
- b.Property("Name")
- .HasColumnType("TEXT");
-
- b.HasKey("Name");
-
- b.ToTable("Rune");
- });
-
- modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
- {
- b.Property("Name")
- .HasColumnType("TEXT");
-
- b.Property("RuneName")
- .HasColumnType("TEXT");
-
- b.HasKey("Name");
-
- b.HasIndex("RuneName");
-
- b.ToTable("RunePage", (string)null);
- });
-
- modelBuilder.Entity("EntityFramework.SkillEntity", b =>
- {
- b.Property("Name")
- .HasColumnType("TEXT");
-
- b.Property("ChampionEntityName")
- .HasColumnType("TEXT");
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Type")
- .HasColumnType("INTEGER");
-
- b.HasKey("Name");
-
- b.HasIndex("ChampionEntityName");
-
- b.ToTable("SkillEntity");
- });
-
- modelBuilder.Entity("EntityFramework.SkinEntity", b =>
- {
- b.Property("Name")
- .ValueGeneratedOnAdd()
- .HasColumnType("TEXT");
-
- b.Property("ChampionEntityForeignKey")
- .HasColumnType("TEXT");
-
- b.Property("Description")
- .HasColumnType("TEXT");
-
- b.Property("Icon")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Image")
- .HasColumnType("TEXT");
-
- b.Property("Price")
- .HasColumnType("REAL");
-
- b.HasKey("Name");
-
- b.HasIndex("ChampionEntityForeignKey");
-
- b.ToTable("Skins");
- });
-
- modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
- {
- b.HasOne("EntityFramework.ChampionEntity", null)
- .WithMany()
- .HasForeignKey("ChampionName")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("EntityFramework.RunePageEntity", null)
- .WithMany()
- .HasForeignKey("RunePageEntitiesName")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
- {
- b.HasOne("EntityFramework.RuneEntity", "Rune")
- .WithMany()
- .HasForeignKey("RuneName");
-
- b.Navigation("Rune");
- });
-
- modelBuilder.Entity("EntityFramework.SkillEntity", b =>
- {
- b.HasOne("EntityFramework.ChampionEntity", null)
- .WithMany("Skills")
- .HasForeignKey("ChampionEntityName");
- });
-
- modelBuilder.Entity("EntityFramework.SkinEntity", b =>
- {
- b.HasOne("EntityFramework.ChampionEntity", "Champion")
- .WithMany("skins")
- .HasForeignKey("ChampionEntityForeignKey");
-
- b.Navigation("Champion");
- });
-
- modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
- {
- b.Navigation("Skills");
-
- b.Navigation("skins");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Sources/EntityFramework/Program.cs b/Sources/EntityFramework/Program.cs
index dfe3c7e..56915f8 100644
--- a/Sources/EntityFramework/Program.cs
+++ b/Sources/EntityFramework/Program.cs
@@ -1,5 +1,6 @@
// See https://aka.ms/new-console-template for more information
using EntityFramework;
+using EntityFramework.Manager;
using Microsoft.EntityFrameworkCore;
using Model;
using System.Buffers.Text;
@@ -37,44 +38,64 @@ using ( var context = new LoLDbContext())
context.SaveChanges();
+IDataManager dataManager = new EFDataManager();
+IChampionsManager championsManager = dataManager.ChampionsMgr;
+IEnumerable champions = await championsManager.GetItemsByName("A", 0, 1);
+Console.WriteLine(champions.First().Name);
- //OneToMany
- Console.WriteLine("Champions : ");
- foreach (var champi in context.Champions.Include(a => a.skins))
- {
- Console.WriteLine($"\t{champi.Name} : {champi.Bio}");
- foreach (var s in champi.skins)
- {
- Console.WriteLine($"\t\t{s.Name}");
- }
- }
- Console.WriteLine();
+//using ( var context = new LoLDbContext())
+//{
+// //context.Add(new ChampionEntity{ Name = "test", Bio = "test", Icon = "test" } );
+// context.SaveChanges();
- Console.WriteLine("Skin :");
- foreach (var s in context.Skins)
- {
- Console.WriteLine($"\t{s.Name}: {s.Description} (Champion : {s.Champion.Name})");
- }
+// ChampionEntity champ = context.Find("Akali");
+// if( champ != null)
+// {
+// Console
+// .WriteLine(champ.ToString());
- Console.WriteLine("\nAjout d'un Champion et 6 Skins...\n");
+// }
+// else
+// {
+// Console.WriteLine("Not Found");
+// }
- ChampionEntity captainMarvel = new ChampionEntity { Name = "Captain Marvel", Bio="Mais que fait un avenger ici ??", Icon="Icon.png"};
- SkinEntity[] skins = { new SkinEntity {Name = "La Fiesta", Champion = captainMarvel},
- new SkinEntity { Name = "Five Hundred Miles High", Champion = captainMarvel },
- new SkinEntity { Name = "Captain Marvel", Champion = captainMarvel },
- new SkinEntity { Name = "Time's Lie", Champion = captainMarvel },
- new SkinEntity { Name = "Lush Life", Champion = captainMarvel },
- new SkinEntity { Name = "Day Waves", Champion = captainMarvel }
- };
- foreach (var s in skins)
- {
- captainMarvel.skins.Add(s);
- }
+// //Test BDD Skills
+// ChampionEntity champSkill = new ChampionEntity { Name="nomSkill", Bio="bioSkill", Icon="iconSkill" };
- context.Add(captainMarvel);
- context.SaveChanges();
+// //SkillEntity s1 = new SkillEntity { Name = "Skill1", Description = "desc", Type = SkillType.Unknown };
+// SkillEntity s2 = new SkillEntity { Name="Skill2", Description="desc2", Type=SkillType.Ultimate };
+// SkillEntity s3 = new SkillEntity { Name = "Skill3", Description = "desc3", Type = SkillType.Passive };
+
+// champSkill.AddSkill(new SkillEntity { Name = "Skill1", Description = "desc", Type = SkillType.Unknown });
+// champSkill.AddSkill(s2);
+// champSkill.AddSkill(s3);
+
+// context.Add(champSkill);
+
+// context.SaveChanges();
+
+
+// //OneToMany
+// Console.WriteLine("Champions : ");
+// foreach (var champi in context.Champions.Include(a => a.skins))
+// {
+// Console.WriteLine($"\t{champi.Name} : {champi.Bio}");
+// foreach (var s in champi.skins)
+// {
+// Console.WriteLine($"\t\t{s.Name}");
+// }
+// }
+
+// Console.WriteLine();
+
+// Console.WriteLine("Skin :");
+// foreach (var s in context.Skins)
+// {
+// Console.WriteLine($"\t{s.Name}: {s.Description} (Champion : {s.Champion.Name})");
+// }
var r1 = new RuneEntity { Name = "Rune1", Description = "aaa", Family = EnumRuneFamily.Domination, Image = new LargeImage("base") };
@@ -89,3 +110,23 @@ using ( var context = new LoLDbContext())
context.RunePage.AddRange(new[] { rp1, rp2 });
context.SaveChanges();
}
+// Console.WriteLine("\nAjout d'un Champion et 6 Skins...\n");
+
+// ChampionEntity captainMarvel = new ChampionEntity { Name = "Captain Marvel", Bio="Mais que fait un avenger ici ??", Icon="Icon.png"};
+// SkinEntity[] skins = { new SkinEntity {Name = "La Fiesta", Champion = captainMarvel},
+// new SkinEntity { Name = "Five Hundred Miles High", Champion = captainMarvel },
+// new SkinEntity { Name = "Captain Marvel", Champion = captainMarvel },
+// new SkinEntity { Name = "Time's Lie", Champion = captainMarvel },
+// new SkinEntity { Name = "Lush Life", Champion = captainMarvel },
+// new SkinEntity { Name = "Day Waves", Champion = captainMarvel }
+// };
+// foreach (var s in skins)
+// {
+// captainMarvel.skins.Add(s);
+// }
+
+// context.Add(captainMarvel);
+// context.SaveChanges();
+
+
+//}
diff --git a/Sources/EntityFramework/champion.db b/Sources/EntityFramework/champion.db
deleted file mode 100644
index acdfad4..0000000
Binary files a/Sources/EntityFramework/champion.db and /dev/null differ
diff --git a/Sources/HttpClient/HttpClient.csproj b/Sources/HttpClient/HttpClient.csproj
new file mode 100644
index 0000000..9e4e01f
--- /dev/null
+++ b/Sources/HttpClient/HttpClient.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/HttpClient/HttpClientManager.Champion.cs b/Sources/HttpClient/HttpClientManager.Champion.cs
new file mode 100644
index 0000000..9ffc79b
--- /dev/null
+++ b/Sources/HttpClient/HttpClientManager.Champion.cs
@@ -0,0 +1,128 @@
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http.Json;
+using System.Reflection;
+using System.Reflection.Metadata;
+using System.Runtime.ConstrainedExecution;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HttpClient
+{
+ public partial class HttpClientManager
+ {
+ public class ChampionManager : IChampionsManager
+ {
+
+
+ private readonly HttpClientManager parent;
+
+ private System.Net.Http.HttpClient httpc;
+
+ public string BaseAddress;
+
+
+ public ChampionManager(HttpClientManager parent, System.Net.Http.HttpClient httpc) {
+
+ this.httpc = httpc;
+ this.parent = parent;
+ }
+
+ public async Task AddItem(Champion? item) //return le champion ajouté, null sinon ?
+ {
+ if(item==null) throw new ArgumentNullException("item is null");
+ var response = await httpc.PostAsJsonAsync("/Champion?Name = " + item.Name, item);
+
+ return response.IsSuccessStatusCode ? item : null;
+ }
+
+ public async Task DeleteItem(Champion? item)
+ {
+ HttpResponseMessage response = await httpc.DeleteAsync("/Champion?Name=" + item.Name);
+ return response.IsSuccessStatusCode;
+ }
+
+ public Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ return httpc.GetFromJsonAsync>("/Champion?index="+index+"&size="+count);
+ }
+
+
+
+
+
+ public Task> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ return httpc.GetFromJsonAsync>("/Champion?name="+substring+"&index=" + index + "&size=" + count);
+ }
+
+ public Task> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItems()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsByCharacteristic(string charName)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsByClass(ChampionClass championClass)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsByName(string substring)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsByRunePage(RunePage? runePage)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsBySkill(Skill? skill)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task GetNbItemsBySkill(string skill)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task UpdateItem(Champion? oldItem, Champion? newItem)
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/Sources/HttpClient/HttpClientManager.cs b/Sources/HttpClient/HttpClientManager.cs
new file mode 100644
index 0000000..49ddb70
--- /dev/null
+++ b/Sources/HttpClient/HttpClientManager.cs
@@ -0,0 +1,29 @@
+using Model;
+
+namespace HttpClient
+{
+ public partial class HttpClientManager : IDataManager
+ {
+
+
+ public System.Net.Http.HttpClient httpC { get; set; } = new System.Net.Http.HttpClient();
+
+ public string BaseAddress;
+
+
+ public HttpClientManager() {
+ ChampionsMgr = new ChampionManager(this, httpC);
+ httpC.BaseAddress = new Uri("https://localhost:7144/api/");
+
+ }
+
+ public ISkinsManager SkinsMgr => throw new NotImplementedException();
+
+ public IRunesManager RunesMgr => throw new NotImplementedException();
+
+ public IRunePagesManager RunePagesMgr => throw new NotImplementedException();
+
+ public IChampionsManager ChampionsMgr { get; set; }
+
+ }
+}
diff --git a/Sources/LeagueOfLegends.sln b/Sources/LeagueOfLegends.sln
index a5d27bb..007e972 100644
--- a/Sources/LeagueOfLegends.sln
+++ b/Sources/LeagueOfLegends.sln
@@ -26,6 +26,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api_UT", "Api_UT\Api_UT.csp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EF_UT", "EF_UT\EF_UT.csproj", "{74F469C3-A94A-4507-9DC7-7DBADCD18173}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient", "HttpClient\HttpClient.csproj", "{DE2E40D5-1B4D-491C-B7E7-4E91B32DB93F}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -64,6 +66,10 @@ Global
{74F469C3-A94A-4507-9DC7-7DBADCD18173}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74F469C3-A94A-4507-9DC7-7DBADCD18173}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74F469C3-A94A-4507-9DC7-7DBADCD18173}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DE2E40D5-1B4D-491C-B7E7-4E91B32DB93F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DE2E40D5-1B4D-491C-B7E7-4E91B32DB93F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DE2E40D5-1B4D-491C-B7E7-4E91B32DB93F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DE2E40D5-1B4D-491C-B7E7-4E91B32DB93F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Sources/StubLib/StubData.Champions.cs b/Sources/StubLib/StubData.Champions.cs
index ad19275..90a33d9 100644
--- a/Sources/StubLib/StubData.Champions.cs
+++ b/Sources/StubLib/StubData.Champions.cs
@@ -8,7 +8,7 @@ namespace StubLib
private List champions = new()
{
new Champion("Akali", ChampionClass.Assassin),
- new Champion("Aatrox", ChampionClass.Fighter),
+ new Champion("Aatrox", ChampionClass.Fighter),
new Champion("Ahri", ChampionClass.Mage),
new Champion("Akshan", ChampionClass.Marksman),
new Champion("Bard", ChampionClass.Support),