|
|
|
@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Model;
|
|
|
|
|
using API_LoL_Project.Controllers.Response;
|
|
|
|
|
using API_LoL_Project.Middleware;
|
|
|
|
|
using ApiMappeur;
|
|
|
|
|
using API_LoL_Project.Controllers.Response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
@ -29,8 +31,8 @@ namespace API_LoL_Project.Controllers.version2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*// GET: api/<RuneController>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
// GET: api/rune
|
|
|
|
|
[HttpGet("/all")]
|
|
|
|
|
public async Task<ActionResult<IEnumerable<RuneDTO>>> GetAllRunes([FromQuery] Request.PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -44,14 +46,14 @@ namespace API_LoL_Project.Controllers.version2
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(GetAllRunes), request); ;
|
|
|
|
|
var runes = await dataManager.GetItems(request.index, request.count, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
|
|
|
|
|
IEnumerable<RuneDTO> res = runes.Select(c => c.toDTO());
|
|
|
|
|
IEnumerable<RuneDTO> res = runes.Select(c => c.ToDTO());
|
|
|
|
|
if (res.Count() <= 0 || res == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("No runes found the total count is {totalcount} ", totalcount);
|
|
|
|
|
return BadRequest("No runes found : totalcount is : " + totalcount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var respList = res.Select(r => new LolResponce<RuneDTO>
|
|
|
|
|
var respList = res.Select(r => new LolResponse<RuneDTO>
|
|
|
|
|
(
|
|
|
|
|
r,
|
|
|
|
|
new List<EndPointLink>
|
|
|
|
@ -61,7 +63,6 @@ namespace API_LoL_Project.Controllers.version2
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"),
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self"),
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self","POST"),
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"),
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
@ -76,16 +77,16 @@ namespace API_LoL_Project.Controllers.version2
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GET: api/<RuneController>
|
|
|
|
|
/* [HttpGet]
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var totalcount = await runesManager.GetNbItems();
|
|
|
|
|
var totalcount = await dataManager.GetNbItems();
|
|
|
|
|
if (request.count + request.index > totalcount)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("to many rows ask the max is {totalcount}", totalcount);
|
|
|
|
@ -94,8 +95,8 @@ namespace API_LoL_Project.Controllers.version2
|
|
|
|
|
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
|
|
|
|
|
IEnumerable<RuneDTO> res = runes.Select(c => c.toDTO());
|
|
|
|
|
var runes = await dataManager.GetItems(request.index, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
|
|
|
|
|
IEnumerable<RuneDTO> res = runes.Select(c => c.ToDTO());
|
|
|
|
|
if (res.Count() >= 0 || res == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No runes found with Id");
|
|
|
|
@ -112,10 +113,10 @@ namespace API_LoL_Project.Controllers.version2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("{name}")]
|
|
|
|
|
public async Task<ActionResult<LolResponce<RuneDTO>>> GetRuneByName(string name)
|
|
|
|
|
public async Task<ActionResult<LolResponse<RuneDTO>>> GetRuneByName(string name)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -123,7 +124,7 @@ namespace API_LoL_Project.Controllers.version2
|
|
|
|
|
var rune = await dataManager
|
|
|
|
|
.GetItemsByName(name, 0, await dataManager.GetNbItems());
|
|
|
|
|
_logger.LogInformation("Executing {Action} with name : {runeName}", nameof(GetRuneByName), name);
|
|
|
|
|
RuneDTO res = rune.First().toDTO();
|
|
|
|
|
RuneDTO res = rune.First().ToDTO();
|
|
|
|
|
|
|
|
|
|
if (res == null)
|
|
|
|
|
{
|
|
|
|
@ -137,53 +138,18 @@ namespace API_LoL_Project.Controllers.version2
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{res.Name}/", "self")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var response = new LolResponce<RuneDTO>(res, links);
|
|
|
|
|
var response = new LolResponse<RuneDTO>(res, links);
|
|
|
|
|
return Ok(response);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message);
|
|
|
|
|
_logger.LogError("Somthing goes wrong catching bt the Runnes controller : " + e.Message);
|
|
|
|
|
return BadRequest(e.Message);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/* // GET api/<RuneController>/5
|
|
|
|
|
[HttpGet("{id}")]
|
|
|
|
|
public string Get(int id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var rune = await dataManager
|
|
|
|
|
.GetItemsByName(name, 0, await dataManager.GetNbItems());
|
|
|
|
|
RuneDto result = champion.First().toDTO();
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
|
|
|
|
catch (Exeption e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
new HttpException(400, 'Cannot get rune :' + e.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
// POST api/<RuneController>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PUT api/<RuneController>/5
|
|
|
|
|
[HttpPut("{id}")]
|
|
|
|
|
public void Put(int id, [FromBody] string value)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DELETE api/<RuneController>/5
|
|
|
|
|
[HttpDelete("{id}")]
|
|
|
|
|
public void Delete(int id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|