From 37a380fed9df288db0fd5f6e34dc41732a4fc371 Mon Sep 17 00:00:00 2001 From: Louwar Date: Mon, 6 Feb 2023 18:25:46 +0100 Subject: [PATCH] Fix bug nommage --- Sources/API/Controllers/ChampionController.cs | 19 ++++++++++++++++++- Sources/API/Mapping/ChampionMapper.cs | 8 ++++---- Sources/ConsoleAPI/ConsoleAPI.csproj | 2 +- .../EFlib/{Champion.cs => EntityChampion.cs} | 2 +- Sources/EFlib/SQLiteContext.cs | 2 +- Sources/EFlib/SqlServerContext.cs | 2 +- 6 files changed, 26 insertions(+), 9 deletions(-) rename Sources/EFlib/{Champion.cs => EntityChampion.cs} (93%) diff --git a/Sources/API/Controllers/ChampionController.cs b/Sources/API/Controllers/ChampionController.cs index 4e1760f..7b5fb5c 100644 --- a/Sources/API/Controllers/ChampionController.cs +++ b/Sources/API/Controllers/ChampionController.cs @@ -1,8 +1,10 @@ using API.Dto; +using API.Mapping; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Model; using Newtonsoft.Json; +using StubLib; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; @@ -17,15 +19,30 @@ namespace API.Controllers { private readonly ILogger _logger; private readonly HttpClient _client; - private const string Apichampion = "api/champion"; private readonly IDataManager dataManager; + private const string Apichampion = "api/champion"; + public ChampionController(IDataManager datamanager, ILogger logger) { _logger = logger; this.dataManager = datamanager; } + [HttpGet] + public async Task> Get() + { + StubData stub = new StubData(); + + IEnumerable listeChamp = await stub.ChampionsMgr.GetItems(0, stub.ChampionsMgr.GetNbItems().Result); + + List champs = new List(); + + listeChamp.ToList().ForEach(c => champs.Add(c.ToDto())); + return Ok(champs); + } + + [HttpGet] [Route("{id}")] public ActionResult> GetById() diff --git a/Sources/API/Mapping/ChampionMapper.cs b/Sources/API/Mapping/ChampionMapper.cs index ddce066..c6ef8bc 100644 --- a/Sources/API/Mapping/ChampionMapper.cs +++ b/Sources/API/Mapping/ChampionMapper.cs @@ -1,5 +1,5 @@ using API.Dto; -using EFlib; +using Model; namespace API.Mapping { @@ -14,13 +14,13 @@ namespace API.Mapping return new ChampionDto { - Id = champion.Id, + //Id = champion.Id, Name = champion.Name, // je peux décider de mettre le nom en minuscule pour que le json est des noms en minuscule Bio = champion.Bio, }; } - public static Champion ToChampion(this ChampionDto championDto) + /*public static Champion ToChampion(this ChampionDto championDto) { if (championDto == null) { @@ -34,6 +34,6 @@ namespace API.Mapping Bio = championDto.Bio, Icon = null }; - } + }*/ } } diff --git a/Sources/ConsoleAPI/ConsoleAPI.csproj b/Sources/ConsoleAPI/ConsoleAPI.csproj index 74abf5c..b473309 100644 --- a/Sources/ConsoleAPI/ConsoleAPI.csproj +++ b/Sources/ConsoleAPI/ConsoleAPI.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/Sources/EFlib/Champion.cs b/Sources/EFlib/EntityChampion.cs similarity index 93% rename from Sources/EFlib/Champion.cs rename to Sources/EFlib/EntityChampion.cs index a802c84..bd01388 100644 --- a/Sources/EFlib/Champion.cs +++ b/Sources/EFlib/EntityChampion.cs @@ -1,6 +1,6 @@ namespace EFlib { - public class Champion + public class EntityChampion { /**** Attributs ****/ public int Id { get; set; } diff --git a/Sources/EFlib/SQLiteContext.cs b/Sources/EFlib/SQLiteContext.cs index d3c053e..cfbbdbe 100644 --- a/Sources/EFlib/SQLiteContext.cs +++ b/Sources/EFlib/SQLiteContext.cs @@ -11,7 +11,7 @@ namespace EFlib public class SQLiteContext : DbContext { /**** Attributs ****/ - public DbSet Champions { get; set; } + public DbSet Champions { get; set; } /**** Méthodes ****/ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) diff --git a/Sources/EFlib/SqlServerContext.cs b/Sources/EFlib/SqlServerContext.cs index 753514e..c63cf7a 100644 --- a/Sources/EFlib/SqlServerContext.cs +++ b/Sources/EFlib/SqlServerContext.cs @@ -10,7 +10,7 @@ namespace EFlib internal class SqlServerContext : DbContext { /**** Attributs ****/ - public DbSet Champions { get; set; } + public DbSet Champions { get; set; } /**** Méthodes ****/ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {