|
|
|
@ -12,6 +12,7 @@ namespace API_LoL_Project.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
|
|
|
|
|
public class RuneController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
public IRunesManager dataManager;
|
|
|
|
@ -28,7 +29,7 @@ namespace API_LoL_Project.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GET: api/<RuneController>
|
|
|
|
|
/*// GET: api/<RuneController>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public async Task<ActionResult<IEnumerable<RuneDTO>>> GetAllRunes([FromQuery] Request.PageRequest request)
|
|
|
|
|
{
|
|
|
|
@ -74,102 +75,103 @@ namespace API_LoL_Project.Controllers
|
|
|
|
|
return BadRequest(e.Message);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GET: api/<RuneController>
|
|
|
|
|
/* [HttpGet]
|
|
|
|
|
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
/* [HttpGet]
|
|
|
|
|
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var totalcount = await runesManager.GetNbItems();
|
|
|
|
|
if (request.count + request.index > totalcount)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("to many rows ask the max is {totalcount}", totalcount);
|
|
|
|
|
return BadRequest("to many rows ask the max is " + totalcount);
|
|
|
|
|
}
|
|
|
|
|
_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());
|
|
|
|
|
if (res.Count() >= 0 || res == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No runes found with Id");
|
|
|
|
|
return BadRequest("No runes found with Id ");
|
|
|
|
|
}
|
|
|
|
|
return Ok(res);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString());
|
|
|
|
|
return BadRequest(e.Message);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
[HttpGet("{name}")]
|
|
|
|
|
public async Task<ActionResult<LolResponce<RuneDTO>>> GetRuneByName(string name)
|
|
|
|
|
{
|
|
|
|
|
var totalcount = await runesManager.GetNbItems();
|
|
|
|
|
if (request.count + request.index > totalcount)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("to many rows ask the max is {totalcount}", totalcount);
|
|
|
|
|
return BadRequest("to many rows ask the max is " + totalcount);
|
|
|
|
|
}
|
|
|
|
|
_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());
|
|
|
|
|
if (res.Count() >= 0 || res == null)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No runes found with Id");
|
|
|
|
|
return BadRequest("No runes found with Id ");
|
|
|
|
|
}
|
|
|
|
|
return Ok(res);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString());
|
|
|
|
|
return BadRequest(e.Message);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
if (res == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No runes found with {name}", name); ;
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
var links = new List<EndPointLink>
|
|
|
|
|
{
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{res.Name}", "self"),
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{res.Name}/", "self"),
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{res.Name}/", "self")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
[HttpGet("{name}")]
|
|
|
|
|
public async Task<ActionResult<LolResponce<RuneDTO>>> GetRuneByName(string name)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
var response = new LolResponce<RuneDTO>(res, links);
|
|
|
|
|
return Ok(response);
|
|
|
|
|
|
|
|
|
|
if (res == null)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("No runes found with {name}", name); ;
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
var links = new List<EndPointLink>
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{res.Name}", "self"),
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{res.Name}/", "self"),
|
|
|
|
|
EndPointLink.To($"/api/[controller]/{res.Name}/", "self")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var response = new LolResponce<RuneDTO>(res, links);
|
|
|
|
|
return Ok(response);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message);
|
|
|
|
|
return BadRequest(e.Message);
|
|
|
|
|
_logger.LogError("Somthing goes wrong caching the Champions 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)
|
|
|
|
|
{
|
|
|
|
|
/* // 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);
|
|
|
|
|
}
|
|
|
|
|
new HttpException(400, 'Cannot get rune :' + e.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
// POST api/<RuneController>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PUT api/<RuneController>/5
|
|
|
|
|
[HttpPut("{id}")]
|
|
|
|
|