You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
69 lines
1.6 KiB
using System.Security.Cryptography;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Model;
|
|
using StubLib;
|
|
using System.Xml.Linq;
|
|
using static StubLib.StubData;
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
namespace apiLOL.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class ControllerChampions : Controller
|
|
{
|
|
private readonly IDataManager data;
|
|
|
|
|
|
|
|
public ControllerChampions(IDataManager manager)
|
|
{
|
|
data = manager;
|
|
}
|
|
|
|
|
|
// GET: api/<ControllerLol>
|
|
[HttpGet]
|
|
public async Task<IActionResult> Get()
|
|
{
|
|
var champs = (await data.ChampionsMgr.GetItems(0, await data.ChampionsMgr.GetNbItems())).Select(Model => Model.ToDTO());
|
|
return Ok(champs);
|
|
}
|
|
|
|
|
|
// GET api/<ControllerLol>/Charle
|
|
[HttpGet]
|
|
[Route("{name}")]
|
|
public async Task<IActionResult> GetChampion(string name)
|
|
{
|
|
var champs = (await data.ChampionsMgr.GetItemsByName(name, 0, 1)).First();
|
|
return Ok(champs.ToDTO());
|
|
}
|
|
|
|
|
|
// POST api/<ControllerLol>
|
|
[HttpPost]
|
|
public IActionResult Post(ChampionDTO champDTO)
|
|
{
|
|
Champion tmp = champDTO.ToModel();
|
|
data.ChampionsMgr.AddItem(tmp);
|
|
return Ok();
|
|
|
|
//return CreatedAtAction(nameof(GetChampion), new { Id = 1 },
|
|
// await data.ChampionsMgr.AddItem(champDTO.ToModel()));
|
|
}
|
|
|
|
// PUT api/<ControllerLol>/5
|
|
[HttpPut("{id}")]
|
|
public void Put(int id, [FromBody] string value)
|
|
{
|
|
}
|
|
|
|
// DELETE api/<ControllerLol>/5
|
|
[HttpDelete("{id}")]
|
|
public void Delete(int id)
|
|
{
|
|
}
|
|
|
|
}
|
|
} |