|
|
|
@ -11,7 +11,9 @@ using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace API_LoL_Project.Controllers
|
|
|
|
|
{
|
|
|
|
|
/*[Route("api/v{version:apiVersion}/[controller]")]*/
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
/*[ApiVersion("1.0")]*/
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class ChampionsController : ControllerBase
|
|
|
|
|
{
|
|
|
|
@ -39,33 +41,59 @@ namespace API_LoL_Project.Controllers
|
|
|
|
|
var totalcount = await dataManager.GetNbItems();
|
|
|
|
|
if (request.count + request.index > totalcount)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No chamions found with Id");
|
|
|
|
|
return BadRequest("No chamions found with Id ");
|
|
|
|
|
_logger.LogWarning("No chamions found");
|
|
|
|
|
return BadRequest("No chamions found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);;
|
|
|
|
|
var champions = await dataManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
|
|
|
|
|
IEnumerable<ChampionDTO> res = champions.Select(c => c.toDTO());
|
|
|
|
|
if (res.Count() >= 0 || res == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No chamions found with Id");
|
|
|
|
|
return BadRequest("No chamions found with Id ");
|
|
|
|
|
_logger.LogWarning("No chamions found ");
|
|
|
|
|
return BadRequest("No chamions found ");
|
|
|
|
|
}
|
|
|
|
|
return Ok(res);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("");
|
|
|
|
|
return BadRequest(e.Message);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*// GET api/<ChampionController>/5
|
|
|
|
|
[HttpGet("{id}")]
|
|
|
|
|
public async Task<ActionResult<IEnumerable<ChampionFullDTO>>> GetChampionsById(int name)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var champion = await dataManager
|
|
|
|
|
.GetItemsByName(name, 0, await dataManager.GetNbItems());
|
|
|
|
|
_logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
|
|
|
|
|
IEnumerable<ChampionFullDTO> res = champion.Select(c => c.toFullDTO());
|
|
|
|
|
|
|
|
|
|
if (res == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No chamions found with {name}", name); ;
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
return Ok(res);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest(e.Message);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GET api/<ChampionController>/5
|
|
|
|
|
[HttpGet("{name}")]
|
|
|
|
|
public async Task<ActionResult<ChampionDTO>> GetChampionsByName(string name)
|
|
|
|
|
public async Task<ActionResult<IEnumerable<ChampionFullDTO>>> GetChampionsByName(string name)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -73,7 +101,8 @@ namespace API_LoL_Project.Controllers
|
|
|
|
|
var champion = await dataManager
|
|
|
|
|
.GetItemsByName(name, 0, await dataManager.GetNbItems());
|
|
|
|
|
_logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
|
|
|
|
|
ChampionDTO res = champion.First().toDTO();
|
|
|
|
|
IEnumerable<ChampionFullDTO> res = champion.Select(c => c.toFullDTO());
|
|
|
|
|
|
|
|
|
|
if (res == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No chamions found with {name}", name); ;
|
|
|
|
@ -187,4 +216,6 @@ namespace API_LoL_Project.Controllers
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|