organisation projet

API2
nathan boileau 2 years ago
parent e2a3c3e463
commit 2dbe282b7b

@ -1,13 +0,0 @@
namespace apiLOL
{
public class ChampionPageDTO
{
public IEnumerable<ChampionDTO> Data { get; set; }
public int Index { get; set; }
public int Count { get; set; }
public int TotalCount { get; set; }
}
}

@ -1,11 +1,12 @@
using System.Security.Cryptography; using System.Security.Cryptography;
using apiLOL.DTO;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Model; using Model;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace apiLOL.Controllers namespace apiLOL.Controllers
{ {
[ApiController] [ApiController]
[Route("api/v1/[controller]")] [Route("api/v1/[controller]")]
[ApiVersion("1.0")] [ApiVersion("1.0")]

@ -0,0 +1,47 @@
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace apiLOL.Controllers
{
[Route("api/[controller]")]
[ApiController]
[ApiVersion("1.0")]
public class ControllerSkin : ControllerBase
{
// GET: api/<ControllerSkin>
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/<ControllerSkin>/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}
// POST api/<ControllerSkin>
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/<ControllerSkin>/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/<ControllerSkin>/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

@ -1,16 +1,16 @@
namespace apiLOL namespace apiLOL.DTO
{ {
public class ChampionDTO public class ChampionDTO
{ {
public ChampionDTO(string name, string bio) public ChampionDTO(string name, string bio)
{ {
Name = name; Name = name;
Bio = bio; Bio = bio;
} }
public string Name { get; set; } public string Name { get; set; }
public string Bio { get; set; } public string Bio { get; set; }
} }
} }

@ -1,18 +1,18 @@
using Model; using Model;
namespace apiLOL namespace apiLOL.DTO
{ {
public static class ChampionMapper public static class ChampionMapper
{ {
public static ChampionDTO ToDTO(this Champion champion) => new ChampionDTO(champion.Name, champion.Bio); public static ChampionDTO ToDTO(this Champion champion) => new ChampionDTO(champion.Name, champion.Bio);
public static Champion ToModel(this ChampionDTO championDTO) public static Champion ToModel(this ChampionDTO championDTO)
{ {
Champion champ = new Champion(championDTO.Name); Champion champ = new Champion(championDTO.Name);
champ.Bio = championDTO.Bio; champ.Bio = championDTO.Bio;
return champ; return champ;
} }
} }
} }

@ -0,0 +1,13 @@
namespace apiLOL.DTO
{
public class ChampionPageDTO
{
public IEnumerable<ChampionDTO> Data { get; set; }
public int Index { get; set; }
public int Count { get; set; }
public int TotalCount { get; set; }
}
}
Loading…
Cancel
Save