diff --git a/.vs/API/v17/.suo b/.vs/API/v17/.suo
new file mode 100644
index 0000000..76b671d
Binary files /dev/null and b/.vs/API/v17/.suo differ
diff --git a/README.md b/README.md
index 1772009..8c2ce49 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,40 @@
-# LolProject
+# LOL-Project
-Realization of an API and an ORM which will be linked to a database in the theme of League of legends
-
+
+**Thème du projet** : Réalisation d'une API et d'un ORM(Entity Framework) qui seront reliés à une base de données dans le thème de League of legends
+
+
+# Répartition du Gitlab
+
+La racine de notre gitlab est composée de deux dossiers essentiels au projet:
+
+[**src**](src) : **Toute la partie codage de l'application**
+
+[**doc**](doc) : **Documentation de l'application**
+
+👉 [**Solution de l'application**](src/EntityFramework_LoL/Sources/LeagueOfLegends.sln)
+
+
+# Environnement de Travail
+
+Mon environnement de travail se base sur plusieurs outils :👇
+
+
+
+---
+
+ 
+ 
+
+---
+
+
+
+# Technicien en charge de l'application
+
+⚙️ Emre KARTAL
+
+
+
+© Groupe 4
+
\ No newline at end of file
diff --git a/doc/Images/Banner.png b/doc/Images/Banner.png
new file mode 100644
index 0000000..8c1d3ef
Binary files /dev/null and b/doc/Images/Banner.png differ
diff --git a/doc/Images/Title-Environnement.png b/doc/Images/Title-Environnement.png
new file mode 100644
index 0000000..3cee147
Binary files /dev/null and b/doc/Images/Title-Environnement.png differ
diff --git a/doc/Images/Title-Fonctionnement.png b/doc/Images/Title-Fonctionnement.png
new file mode 100644
index 0000000..23f0c39
Binary files /dev/null and b/doc/Images/Title-Fonctionnement.png differ
diff --git a/doc/Images/Title-Répartition.png b/doc/Images/Title-Répartition.png
new file mode 100644
index 0000000..6a4fc26
Binary files /dev/null and b/doc/Images/Title-Répartition.png differ
diff --git a/doc/Images/Title-Technicien.png b/doc/Images/Title-Technicien.png
new file mode 100644
index 0000000..2e46f8a
Binary files /dev/null and b/doc/Images/Title-Technicien.png differ
diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs
index c19a41a..e1f2dda 100644
--- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs
+++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs
@@ -2,7 +2,6 @@
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
-using StubLib;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@@ -12,41 +11,50 @@ namespace ApiLol.Controllers
[ApiController]
public class ChampionsController : ControllerBase
{
- IChampionsManager dataManager = new StubData().ChampionsMgr;
+ private readonly IDataManager _manager;
+ public ChampionsController(IDataManager dataManager)
+ {
+ this._manager = dataManager;
+ }
+
// GET: api/
[HttpGet]
public async Task Get()
{
- var champions = await dataManager.GetItems(0, await dataManager.GetNbItems()); // Le await va permettre que les lignes suivantes ne s'éxécute pas
- return Ok(new { result = champions.Select(c => c.ToDto())});
+ IEnumerable dtos = (await _manager.ChampionsMgr.GetItems(0, await _manager.ChampionsMgr.GetNbItems()))
+ .Select(x => x.ToDto());
+ return Ok(dtos);
}
// GET api//5
[HttpGet("{name}")]
- public IActionResult Get(string name)
+ public async Task Get(string name)
{
- dataManager.GetItemsByName(name, 0, 1);
- return NotFound();
+ var dtos = (await _manager.ChampionsMgr.GetItemsByName(name,0, await _manager.ChampionsMgr.GetNbItems()))
+ .Select(x => x.ToDto());
+ return Ok(dtos);
}
// POST api/
[HttpPost]
- public async Task Post([FromBody] ChampionDto value)
+ public async Task Post([FromBody] ChampionDto champion)
{
- //await dataManager.AddItem(value.toModel());
- return Ok();
+ return CreatedAtAction(nameof(Get),
+ await _manager.ChampionsMgr.AddItem(champion.ToModel()));
}
// PUT api//5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
+
}
// DELETE api//5
[HttpDelete("{id}")]
public void Delete(int id)
{
+
}
}
}
diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs
index e56f46d..97fe7ca 100644
--- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs
+++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs
@@ -12,5 +12,11 @@ namespace ApiLol.Mapper
Name = champion.Name,
};
}
+
+ public static Champion ToModel(this ChampionDto championDto)
+ {
+
+ }
+
}
}
diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Program.cs b/src/EntityFramework_LoL/Sources/ApiLol/Program.cs
index 15eacee..5952afd 100644
--- a/src/EntityFramework_LoL/Sources/ApiLol/Program.cs
+++ b/src/EntityFramework_LoL/Sources/ApiLol/Program.cs
@@ -1,3 +1,6 @@
+using Model;
+using StubLib;
+
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@@ -6,6 +9,7 @@ builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
+builder.Services.AddScoped();
var app = builder.Build();
diff --git a/src/EntityFramework_LoL/Sources/Client/ChampionHttpClient.cs b/src/EntityFramework_LoL/Sources/Client/ChampionHttpClient.cs
new file mode 100644
index 0000000..ff63eb9
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Client/ChampionHttpClient.cs
@@ -0,0 +1,42 @@
+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 ApiChampions = "api/champions";
+ private readonly HttpClient _httpClient;
+ public ChampionHttpClient(HttpClient httpClient)
+ {
+ _httpClient = httpClient;
+ httpClient.BaseAddress = new Uri("https://localhost:7252;http://localhost:5252");
+ }
+
+ public async Task> GetChampion()
+ {
+ var champions = await _httpClient.GetFromJsonAsync>(ApiChampions);
+ return champions;
+ }
+ public async void Add(ChampionDto champion)
+ {
+ await _httpClient.PostAsJsonAsync(ApiChampions, champion);
+ }
+
+ public async void Delete(ChampionDto champion)
+ {
+ await _httpClient.DeleteAsync(champion);
+ }
+
+ public async void Update(ChampionDto champion)
+ {
+ await _httpClient.PutAsJsonAsync(ApiChampions, champion);
+ }
+
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/Client/Client.csproj b/src/EntityFramework_LoL/Sources/Client/Client.csproj
new file mode 100644
index 0000000..ea66df3
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Client/Client.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/src/EntityFramework_LoL/Sources/Client/Program.cs b/src/EntityFramework_LoL/Sources/Client/Program.cs
new file mode 100644
index 0000000..3751555
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Client/Program.cs
@@ -0,0 +1,2 @@
+// 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 df59485..5ac870e 100644
--- a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln
+++ b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln
@@ -17,7 +17,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiLol", "ApiLol\ApiLol.csproj", "{D59C9C7B-9BC2-4601-959D-BFA97E46D017}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiTests", "Tests\ApiTests\ApiTests.csproj", "{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{464DAB04-BE65-429D-9A39-3E1BB43C521A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -49,6 +53,14 @@ Global
{3919E408-EB12-4422-989B-C6ED4816D465}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3919E408-EB12-4422-989B-C6ED4816D465}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3919E408-EB12-4422-989B-C6ED4816D465}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {464DAB04-BE65-429D-9A39-3E1BB43C521A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {464DAB04-BE65-429D-9A39-3E1BB43C521A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {464DAB04-BE65-429D-9A39-3E1BB43C521A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {464DAB04-BE65-429D-9A39-3E1BB43C521A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -56,6 +68,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
+ {1779D8A4-2E12-47F3-BDA2-2E7F04B758EB} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9}
diff --git a/src/EntityFramework_LoL/Sources/Tests/ApiTests/ApiTests.csproj b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ApiTests.csproj
new file mode 100644
index 0000000..694988e
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ApiTests.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs
new file mode 100644
index 0000000..b7468b5
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs
@@ -0,0 +1,61 @@
+using ApiLol.Controllers;
+using DTO;
+using Microsoft.AspNetCore.Mvc;
+using Model;
+using StubLib;
+
+namespace ApiTests
+{
+ [TestClass]
+ public class ChampionsControllerTest
+ {
+ private readonly StubData stub;
+ private readonly ChampionsControllerTest champs;
+ public ChampionsControllerTest()
+ {
+ stub = new StubData();
+ champs = new ChampionsController(stub);
+ }
+
+ [TestMethod]
+ public async void TestGetChampions()
+ {
+ //Arrange
+
+ //Act
+ var champion = champs.Get();
+
+ //Assert
+ var objectResult = champion as OkObjectResult;
+ Assert.IsNotNull(objectResult);
+
+ var champions = objectResult?.Value as IEnumerable;
+ Assert.IsNotNull(champions);
+
+ Assert.AreEqual(champions.Count(), await stub.ChampionsMgr.GetItems(0,5).Count());
+
+ }
+
+ [TestMethod]
+ public async Task TestPostChampion()
+ {
+ //Arange
+ var ChampionDto = new ChampionDto
+ {
+ Name = "Sylas"
+ };
+
+ //Act
+ var championsResult = await champs.Post(ChampionDto);
+
+ //Assert
+ var objectResult = championsResult as OkObjectResult;
+ Assert.IsNotNull(objectResult);
+
+ var champions = objectResult?.Value as IEnumerable;
+ Assert.IsNotNull(champions);
+
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/EntityFramework_LoL/Sources/Tests/ApiTests/Usings.cs b/src/EntityFramework_LoL/Sources/Tests/ApiTests/Usings.cs
new file mode 100644
index 0000000..ab67c7e
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Tests/ApiTests/Usings.cs
@@ -0,0 +1 @@
+global using Microsoft.VisualStudio.TestTools.UnitTesting;
\ No newline at end of file