Fix bug nommage

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

@ -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<ChampionController> _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<ChampionController> logger)
{
_logger = logger;
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]
[Route("{id}")]
public ActionResult<IEnumerable<ChampionDto>> GetById()

@ -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
};
}
}*/
}
}

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

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

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

Loading…
Cancel
Save