Fix bug nommage

pull/10/head
Louwar 2 years ago
parent af180eb528
commit 37a380fed9

@ -1,8 +1,10 @@
using API.Dto; using API.Dto;
using API.Mapping;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Model; using Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using StubLib;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
@ -17,15 +19,30 @@ namespace API.Controllers
{ {
private readonly ILogger<ChampionController> _logger; private readonly ILogger<ChampionController> _logger;
private readonly HttpClient _client; private readonly HttpClient _client;
private const string Apichampion = "api/champion";
private readonly IDataManager dataManager; private readonly IDataManager dataManager;
private const string Apichampion = "api/champion";
public ChampionController(IDataManager datamanager, ILogger<ChampionController> logger) public ChampionController(IDataManager datamanager, ILogger<ChampionController> logger)
{ {
_logger = logger; _logger = logger;
this.dataManager = datamanager; this.dataManager = datamanager;
} }
[HttpGet]
public async Task<ActionResult<ChampionDto>> Get()
{
StubData stub = new StubData();
IEnumerable<Champion?> listeChamp = await stub.ChampionsMgr.GetItems(0, stub.ChampionsMgr.GetNbItems().Result);
List<ChampionDto> champs = new List<ChampionDto>();
listeChamp.ToList().ForEach(c => champs.Add(c.ToDto()));
return Ok(champs);
}
[HttpGet] [HttpGet]
[Route("{id}")] [Route("{id}")]
public ActionResult<IEnumerable<ChampionDto>> GetById() public ActionResult<IEnumerable<ChampionDto>> GetById()

@ -1,5 +1,5 @@
using API.Dto; using API.Dto;
using EFlib; using Model;
namespace API.Mapping namespace API.Mapping
{ {
@ -14,13 +14,13 @@ namespace API.Mapping
return new ChampionDto 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 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, Bio = champion.Bio,
}; };
} }
public static Champion ToChampion(this ChampionDto championDto) /*public static Champion ToChampion(this ChampionDto championDto)
{ {
if (championDto == null) if (championDto == null)
{ {
@ -34,6 +34,6 @@ namespace API.Mapping
Bio = championDto.Bio, Bio = championDto.Bio,
Icon = null Icon = null
}; };
} }*/
} }
} }

@ -1,6 +1,6 @@
namespace EFlib namespace EFlib
{ {
public class Champion public class EntityChampion
{ {
/**** Attributs ****/ /**** Attributs ****/
public int Id { get; set; } public int Id { get; set; }

@ -11,7 +11,7 @@ namespace EFlib
public class SQLiteContext : DbContext public class SQLiteContext : DbContext
{ {
/**** Attributs ****/ /**** Attributs ****/
public DbSet<Champion> Champions { get; set; } public DbSet<EntityChampion> Champions { get; set; }
/**** Méthodes ****/ /**** Méthodes ****/
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

@ -10,7 +10,7 @@ namespace EFlib
internal class SqlServerContext : DbContext internal class SqlServerContext : DbContext
{ {
/**** Attributs ****/ /**** Attributs ****/
public DbSet<Champion> Champions { get; set; } public DbSet<EntityChampion> Champions { get; set; }
/**** Méthodes ****/ /**** Méthodes ****/
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {

Loading…
Cancel
Save