|
|
|
@ -8,6 +8,8 @@ using System.Drawing;
|
|
|
|
|
using System;
|
|
|
|
|
using API_LoL.Mapper;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
|
|
|
using System.Reflection.PortableExecutable;
|
|
|
|
|
|
|
|
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
|
|
|
|
|
@ -21,12 +23,17 @@ namespace API_LoL.Controllers
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public ChampionsController(IDataManager Manager) {
|
|
|
|
|
this._logger = LoggerFactory.Create(builder => builder.AddConsole()).CreateLogger<ChampionsController>();
|
|
|
|
|
this.ChampionsManager = Manager.ChampionsMgr;
|
|
|
|
|
this.SkinsManager = Manager.SkinsMgr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private IChampionsManager ChampionsManager;
|
|
|
|
|
private ISkinsManager SkinsManager;
|
|
|
|
|
//private StubData stubData;
|
|
|
|
|
private ILogger logger;
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
|
|
|
|
// GET api/<ChampionController>/5
|
|
|
|
|
|
|
|
|
@ -41,6 +48,7 @@ namespace API_LoL.Controllers
|
|
|
|
|
{
|
|
|
|
|
if (size - index > 10)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(message : "Oversized","Get","/Champion",400,"name : "+name,"skill : "+skill,"characteristics : "+characteristic,"index : "+index,"size : "+size,DateTime.Now);
|
|
|
|
|
return BadRequest();
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(name))
|
|
|
|
@ -81,7 +89,11 @@ namespace API_LoL.Controllers
|
|
|
|
|
[HttpGet("name")]
|
|
|
|
|
public async Task<IActionResult> GetByName(String name)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(name)) return BadRequest();
|
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(message: "No paramater given", "Get", "/Champion/Name", 400, "name : " + name, DateTime.Now);
|
|
|
|
|
return BadRequest();
|
|
|
|
|
}
|
|
|
|
|
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
|
|
|
|
|
if (list.Count() == 1)
|
|
|
|
|
{
|
|
|
|
@ -94,7 +106,11 @@ namespace API_LoL.Controllers
|
|
|
|
|
[HttpGet("name/skins")]
|
|
|
|
|
public async Task<IActionResult> GetSkinsByName(String name)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(name)) return BadRequest();
|
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(message: "No paramater given", "Get", "/Champion/Name/Skins", 400, "name : " + name, DateTime.Now);
|
|
|
|
|
return BadRequest();
|
|
|
|
|
}
|
|
|
|
|
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
|
|
|
|
|
if (list.Count() == 1)
|
|
|
|
|
{
|
|
|
|
@ -134,6 +150,7 @@ namespace API_LoL.Controllers
|
|
|
|
|
{
|
|
|
|
|
if (champion == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(message: "Null paramater given", "Post", "/Champion", 422, "champion : " + champion.toString, DateTime.Now);
|
|
|
|
|
return UnprocessableEntity();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|