Début liaison API -> EF :magic_wand:
continuous-integration/drone/push Build is failing Details

API2
nathan boileau 2 years ago
parent f3bf722d61
commit fb75fbb6be

@ -1,47 +0,0 @@
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)
{
}
}
}

@ -3,14 +3,16 @@
public class ChampionDTO public class ChampionDTO
{ {
public ChampionDTO(string name, string bio) public ChampionDTO(string name, string bio, string icon)
{ {
Name = name; Name = name;
Bio = bio; Bio = bio;
Icon = icon;
} }
public string Name { get; set; } public string Name { get; set; }
public string Bio { get; set; } public string Bio { get; set; }
public string Icon { get; set; }
} }
} }

@ -4,13 +4,14 @@ 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, champion.Icon);
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;
champ.Icon = championDTO.Icon;
return champ; return champ;
} }

@ -0,0 +1,20 @@
using EFLol;
using Model;
namespace apiLOL
{
public class EFDataManager : IDataManager
{
// Connect to the MyDbContext class
private readonly MyDbContext _context;
// Constructor
public EFDataManager(MyDbContext context)
{
_context = context;
}
// Implement the interface
}
}

@ -20,6 +20,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\EFLol\EFLol.csproj" />
<ProjectReference Include="..\Model\Model.csproj" /> <ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\StubLib\StubLib.csproj" /> <ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup> </ItemGroup>

Loading…
Cancel
Save