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.
EfCore_LoL_S4/WebApiLol/Controllers/ChampionController.cs

47 lines
1.1 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using StubLib;
using WebApiLol.Converter;
namespace WebApiLol.Controllers;
[ApiController]
[Route("[controller]")]
public class ChampionController : ControllerBase
{
private StubData.ChampionsManager ChampionsManager { get; set; } = new StubData.ChampionsManager(new StubData());
private readonly ILogger<ChampionController> _logger;
public ChampionController(ILogger<ChampionController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetChampion")]
public ActionResult<IEnumerable<ChampionDTO>> Get()
{
return Ok(Enumerable.Range(1, 5).Select(index => new ChampionDTO
{
UniqueId = 0,
Bio= "Test bio",
Icon="Diamant",
Name="Jax"
})
.ToArray());
}
[HttpPost]
public async Task<IActionResult> AddRune(ChampionDTO champion)
{
var newChampion = champion.toModel();
await ChampionsManager.AddItem(newChampion);
return Ok(newChampion);
}
}