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/.vs/LolProject/v17/.suo b/.vs/LolProject/v17/.suo
index d3190ef..ba8264e 100644
Binary files a/.vs/LolProject/v17/.suo and b/.vs/LolProject/v17/.suo differ
diff --git a/.vs/NApi/v17/.suo b/.vs/NApi/v17/.suo
new file mode 100644
index 0000000..0933ee8
Binary files /dev/null and b/.vs/NApi/v17/.suo differ
diff --git a/README.md b/README.md
index 1772009..9596336 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,99 @@
-# LolProject
+
-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
+
+
+
+
+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)
+
+
+
+
+- ### Comment récupérer le projet ?
+
+Tout d'abord si ce n'est pas fait cloner le dépôt de la branche **master/main**, pour cela copier le lien URL du dépôt git :
+
+
+
+
+
+
+
+Vous pouvez le cloner via un terminal dans le répertoire que vous souhaitez en tapant la commande : **git clone https://codefirst.iut.uca.fr/git/emre.kartal/LolProject.git** ou utiliser Visual Studio et cloner en entrant le lien :
+
+
+
+
+
+
+
+:information_source: *Si vous ne disposez pas de Visual Studio, allé sur le site [Microsoft Visual Studio](https://visualstudio.microsoft.com/fr/downloads/) pour pouvoir le télécharger !!!*
+
+
+- ### Comment lancer Le projet Entity Framework ?
+
+Afin de générer les migrations et les tables.
+
+Vous devez avoir installé correctement EntityFrameworkCore, pour cela il existe la commande : **dotnet tool install --global dotnet-ef** qui peut être lancé à partir d'un terminal, si il est déjà installer mais n'a pas la bonne version : **dotnet tool update --global dotnet-ef** (oui y que le *install* qui change vous êtes perspicace)!
+
+Aussi assurer vous d'avoir installé sur Visual Studio au préalable les package Nuget suivants :
+
+
+
+
+
+
+
+Ensuite sur le terminal PowerShell ou Visual Studio, lancer la migration via la commande : **dotnet ef migrations add monNomDeMigration** (n'oublier pas de vous situer dans le dossier "/MyFlib" lorsque vous l'exécuter)!
+
+- ### Comment voir la base de données ?
+
+C'est bien beau toutes ces étapes mais s’il n'y a pas de résultat à quoi cela sert !
+
+Afin de visualiser la migration dans la base de données, cliquer dans l'onglet **Affichage**->**Explorateur d'objets SQL Server** :
+
+
+
+
+
+
+
+Puis dans l'Explorateur d'objets SQL Server, cliquer sur **SQL Server**-> **(localdb)\MSSQLLocalDB ...**->**Bases de données**
+
+:information_source: *Notez qu'il est également possible d'utiliser l'Explorateur d'objets SQL Server pour ajouter, modifier ou supprimer des données dans les tables.*
+
+
+
+Mon environnement de travail se base sur un outil et un langage en particulier :👇
+
+
+
+---
+
+ 
+ 
+
+---
+
+
+
+
+
+⚙️ Emre KARTAL
+
+
+
+© PM2
+
\ No newline at end of file
diff --git a/doc/Images/Banner.png b/doc/Images/Banner.png
new file mode 100644
index 0000000..c78eef1
Binary files /dev/null and b/doc/Images/Banner.png differ
diff --git a/doc/Images/HowToClone.png b/doc/Images/HowToClone.png
new file mode 100644
index 0000000..43462ec
Binary files /dev/null and b/doc/Images/HowToClone.png differ
diff --git a/doc/Images/Package_Nuget.png b/doc/Images/Package_Nuget.png
new file mode 100644
index 0000000..738788e
Binary files /dev/null and b/doc/Images/Package_Nuget.png differ
diff --git a/doc/Images/PageVS.png b/doc/Images/PageVS.png
new file mode 100644
index 0000000..a28725e
Binary files /dev/null and b/doc/Images/PageVS.png differ
diff --git a/doc/Images/Start_BD.png b/doc/Images/Start_BD.png
new file mode 100644
index 0000000..4955286
Binary files /dev/null and b/doc/Images/Start_BD.png differ
diff --git a/doc/Images/Title-Environnement.png b/doc/Images/Title-Environnement.png
new file mode 100644
index 0000000..b9015b8
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..72ee776
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..de3fe1c
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..ad2f3f2 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,54 @@ 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());
+ if(dtos == null)
+ {
+ return NotFound();
+ }
+ 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())).ToDto());
}
- // PUT api//5
- [HttpPut("{id}")]
- public void Put(int id, [FromBody] string value)
+/* // PUT api//5
+ [HttpPut("{name}")]
+ public async void Put(string name, [FromBody] ChampionDto champion)
{
- }
+ return Ok(await _manager.ChampionsMgr.UpdateItem(, champion.ToModel()));
+ }*/
// DELETE api//5
- [HttpDelete("{id}")]
- public void Delete(int id)
+ [HttpDelete]
+ public async Task Delete([FromBody] ChampionDto champion)
{
+ return Ok(await _manager.ChampionsMgr.DeleteItem(champion.ToModel()));
}
}
}
diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs
index e56f46d..32ab8a7 100644
--- a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs
+++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/ChampionMapper.cs
@@ -10,7 +10,17 @@ namespace ApiLol.Mapper
return new ChampionDto()
{
Name = champion.Name,
+ Bio = champion.Bio,
};
}
+
+ public static Champion ToModel(this ChampionDto championDto)
+ {
+ return new Champion(championDto.Name)
+ {
+ Bio = championDto.Bio,
+ };
+ }
+
}
}
diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs
new file mode 100644
index 0000000..fcd88a6
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/RuneMapper.cs
@@ -0,0 +1,25 @@
+using DTO;
+using Model;
+
+namespace ApiLol.Mapper
+{
+ public static class RuneMapper
+ {
+ public static RuneDto ToDto(this Rune rune)
+ {
+ return new RuneDto()
+ {
+ Name = rune.Name,
+ Description = rune.Description,
+ };
+ }
+
+/* public static Rune ToModel(this RuneDto rune)
+ {
+ return new Rune(rune.Name)
+ {
+ Description = rune.Description,
+ };
+ }*/
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs
new file mode 100644
index 0000000..768caf7
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/ApiLol/Mapper/SkillMapper.cs
@@ -0,0 +1,25 @@
+using DTO;
+using Model;
+
+namespace ApiLol.Mapper
+{
+ public static class SkillMapper
+ {
+ public static SkillDto ToDto(this Skill skill)
+ {
+ return new SkillDto()
+ {
+ Name = skill.Name,
+ Description = skill.Description,
+ };
+ }
+
+/* public static Skill ToModel(this SkillDto skill)
+ {
+ return new Skill(skill.Name)
+ {
+ Description = skill.Description
+ };
+ }*/
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/ApiLol/Program.cs b/src/EntityFramework_LoL/Sources/ApiLol/Program.cs
index 15eacee..e6ed0a5 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.AddSingleton();
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..2fa8957
--- /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/DTO/ChampionDto.cs b/src/EntityFramework_LoL/Sources/DTO/ChampionDto.cs
index 5c7ecf2..f19a03b 100644
--- a/src/EntityFramework_LoL/Sources/DTO/ChampionDto.cs
+++ b/src/EntityFramework_LoL/Sources/DTO/ChampionDto.cs
@@ -3,5 +3,6 @@
public class ChampionDto
{
public string Name { get; set; }
+ public string Bio { get; set; }
}
}
\ No newline at end of file
diff --git a/src/EntityFramework_LoL/Sources/DTO/RuneDto.cs b/src/EntityFramework_LoL/Sources/DTO/RuneDto.cs
new file mode 100644
index 0000000..f5afb80
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/DTO/RuneDto.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTO
+{
+ public class RuneDto
+ {
+ public string Name { get; set; }
+ public string Description { get; set; }
+
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/DTO/SkillDto.cs b/src/EntityFramework_LoL/Sources/DTO/SkillDto.cs
new file mode 100644
index 0000000..77372ab
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/DTO/SkillDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTO
+{
+ public class SkillDto
+ {
+ public string Name { get; set; }
+ public string Description { get; set; }
+ }
+}
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..a0b976c
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs
@@ -0,0 +1,62 @@
+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 ChampionsController champs;
+ public ChampionsControllerTest()
+ {
+ stub = new StubData();
+ champs = new ChampionsController(stub);
+ }
+
+ [TestMethod]
+ public async Task TestGetChampions()
+ {
+ //Arrange
+
+ //Act
+ var champion = await 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.GetNbItems());
+
+ }
+
+ [TestMethod]
+ public async Task TestPostChampion()
+ {
+ //Arange
+ var ChampionDto = new ChampionDto
+ {
+ Name = "Sylas",
+ Bio = "Good"
+ };
+
+ //Act
+ var championsResult = await champs.Post(ChampionDto);
+
+ //Assert
+ var objectResult = championsResult as CreatedAtActionResult;
+ Assert.IsNotNull(objectResult);
+
+ var champions = objectResult?.Value as Champion;
+ 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