diff --git a/Sources/ApiDePaul/ApiDePaul.csproj b/Sources/ApiDePaul/ApiDePaul.csproj new file mode 100644 index 0000000..eb51bcd --- /dev/null +++ b/Sources/ApiDePaul/ApiDePaul.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/Sources/ApiDePaul/Controllers/ChampionController.cs b/Sources/ApiDePaul/Controllers/ChampionController.cs new file mode 100644 index 0000000..b5b661e --- /dev/null +++ b/Sources/ApiDePaul/Controllers/ChampionController.cs @@ -0,0 +1,117 @@ +using ApiDePaul.DTO; +using Microsoft.AspNetCore.Mvc; +using Model; +using StubLib; +using System.Collections.Generic; + +namespace ApiDePaul.Controllers +{ + [ApiController] + [Route("[controller]")] + public class ChampionController : ControllerBase + { + private readonly ILogger _logger; + + public ChampionController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public async Task> Get() + { + StubData stu = new StubData(); + + IEnumerable lcha = await stu.ChampionsMgr.GetItems(0, stu.ChampionsMgr.GetNbItems().Result); + + List champs = new List(); + + lcha.ToList().ForEach(c => champs.Add(c.ChampToDto())); + return Ok(champs); + } + + [HttpGet("{id}")] + public async Task> Get(int id) + { + StubData stu = new StubData(); + + + IEnumerable lcha = await stu.ChampionsMgr.GetItems(id, 1); + + if (id >= 0 && id < stu.ChampionsMgr.GetNbItems().Result) + { + return Ok(lcha.First().ChampToDto()); + } + return BadRequest(); + } + /* + // GET: ChampionController/Details/5 + public ActionResult Details(int id) + { + return View(); + } + + // GET: ChampionController/Create + public ActionResult Create() + { + return View(); + } + + // POST: ChampionController/Create + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Create(IFormCollection collection) + { + try + { + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + + // GET: ChampionController/Edit/5 + public ActionResult Edit(int id) + { + return View(); + } + + // POST: ChampionController/Edit/5 + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Edit(int id, IFormCollection collection) + { + try + { + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + + // GET: ChampionController/Delete/5 + public ActionResult Delete(int id) + { + return View(); + } + + // POST: ChampionController/Delete/5 + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Delete(int id, IFormCollection collection) + { + try + { + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + }*/ + } +} diff --git a/Sources/ApiDePaul/Controllers/WeatherForecastController.cs b/Sources/ApiDePaul/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..508fe53 --- /dev/null +++ b/Sources/ApiDePaul/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ApiDePaul.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} \ No newline at end of file diff --git a/Sources/ApiDePaul/Conversion/ChampionMapping.cs b/Sources/ApiDePaul/Conversion/ChampionMapping.cs new file mode 100644 index 0000000..604bbb1 --- /dev/null +++ b/Sources/ApiDePaul/Conversion/ChampionMapping.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ApiDePaul.DTO; +using Model; + +namespace ApiDePaul +{ + public static class ChampionMapping + { + public static ChampionDto ChampToDto(this Champion c) + { + return new ChampionDto() + { + Name = c.Name, + Bio = c.Bio, + Icon = c.Icon + }; + } + public static Champion DtoToChamp(this ChampionDto c) => new Champion(c.Name); + } +} \ No newline at end of file diff --git a/Sources/ApiDePaul/DTO/ChampionDto.cs b/Sources/ApiDePaul/DTO/ChampionDto.cs new file mode 100644 index 0000000..3d289c9 --- /dev/null +++ b/Sources/ApiDePaul/DTO/ChampionDto.cs @@ -0,0 +1,16 @@ +using Model; + +namespace ApiDePaul.DTO +{ + public class ChampionDto + { + public string Name { get; set; } + public string Bio { get; set; } + public String Class { get; set; } + public string Icon { get; set; } + public String Image { get; set; } + public List Skins { get; set; } + public Dictionary Characteristics { get; set; } + public HashSet Skills { get; set; } + } +} diff --git a/Sources/ApiDePaul/DTO/SkinDto.cs b/Sources/ApiDePaul/DTO/SkinDto.cs new file mode 100644 index 0000000..6e8a4e4 --- /dev/null +++ b/Sources/ApiDePaul/DTO/SkinDto.cs @@ -0,0 +1,6 @@ +namespace ApiDePaul.DTO +{ + public class SkinDto + { + } +} diff --git a/Sources/ApiDePaul/Program.cs b/Sources/ApiDePaul/Program.cs new file mode 100644 index 0000000..a3ec0d0 --- /dev/null +++ b/Sources/ApiDePaul/Program.cs @@ -0,0 +1,28 @@ +using Model; +using StubLib; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +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(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Sources/ApiDePaul/Properties/launchSettings.json b/Sources/ApiDePaul/Properties/launchSettings.json new file mode 100644 index 0000000..0205c38 --- /dev/null +++ b/Sources/ApiDePaul/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:15019", + "sslPort": 44321 + } + }, + "profiles": { + "ApiDePaul": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7065;http://localhost:5065", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Sources/ApiDePaul/WeatherForecast.cs b/Sources/ApiDePaul/WeatherForecast.cs new file mode 100644 index 0000000..1e0fd97 --- /dev/null +++ b/Sources/ApiDePaul/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace ApiDePaul +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} \ No newline at end of file diff --git a/Sources/ApiDePaul/appsettings.Development.json b/Sources/ApiDePaul/appsettings.Development.json new file mode 100644 index 0000000..ff66ba6 --- /dev/null +++ b/Sources/ApiDePaul/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Sources/ApiDePaul/appsettings.json b/Sources/ApiDePaul/appsettings.json new file mode 100644 index 0000000..4d56694 --- /dev/null +++ b/Sources/ApiDePaul/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Sources/LeagueOfLegends.sln b/Sources/LeagueOfLegends.sln index 778c200..d81a4f4 100644 --- a/Sources/LeagueOfLegends.sln +++ b/Sources/LeagueOfLegends.sln @@ -17,19 +17,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibEntityFramework", "Model2\LibEntityFramework.csproj", "{D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BddTests", "BddTests\BddTests.csproj", "{20E7E2FA-9482-4F46-AE84-97576399F882}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BddTests", "BddTests\BddTests.csproj", "{20E7E2FA-9482-4F46-AE84-97576399F882}" ProjectSection(ProjectDependencies) = postProject {00B54DCE-F7B5-4C3A-AC91-EF6BAB1AD36C} = {00B54DCE-F7B5-4C3A-AC91-EF6BAB1AD36C} {2960F9BA-49DE-494D-92E3-CE5A794BA1A9} = {2960F9BA-49DE-494D-92E3-CE5A794BA1A9} {D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5} = {D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrucAuMilieu", "TrucAuMilieu\TrucAuMilieu.csproj", "{00B54DCE-F7B5-4C3A-AC91-EF6BAB1AD36C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrucAuMilieu", "TrucAuMilieu\TrucAuMilieu.csproj", "{00B54DCE-F7B5-4C3A-AC91-EF6BAB1AD36C}" ProjectSection(ProjectDependencies) = postProject {2960F9BA-49DE-494D-92E3-CE5A794BA1A9} = {2960F9BA-49DE-494D-92E3-CE5A794BA1A9} {D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5} = {D7FE55BA-1CEE-4C9D-B2FA-674D61F1B7A5} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiDePaul", "ApiDePaul\ApiDePaul.csproj", "{245F7BAC-8487-4510-8066-D12B5B2B816B}" + ProjectSection(ProjectDependencies) = postProject + {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -64,6 +69,10 @@ Global {00B54DCE-F7B5-4C3A-AC91-EF6BAB1AD36C}.Debug|Any CPU.Build.0 = Debug|Any CPU {00B54DCE-F7B5-4C3A-AC91-EF6BAB1AD36C}.Release|Any CPU.ActiveCfg = Release|Any CPU {00B54DCE-F7B5-4C3A-AC91-EF6BAB1AD36C}.Release|Any CPU.Build.0 = Release|Any CPU + {245F7BAC-8487-4510-8066-D12B5B2B816B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {245F7BAC-8487-4510-8066-D12B5B2B816B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {245F7BAC-8487-4510-8066-D12B5B2B816B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {245F7BAC-8487-4510-8066-D12B5B2B816B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Sources/TrucAuMilieu/TrucAuMilieu.csproj b/Sources/TrucAuMilieu/TrucAuMilieu.csproj index 446c0c5..bf2fdb7 100644 --- a/Sources/TrucAuMilieu/TrucAuMilieu.csproj +++ b/Sources/TrucAuMilieu/TrucAuMilieu.csproj @@ -7,6 +7,7 @@ +