|
|
@ -4,7 +4,6 @@ using DTO;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Model;
|
|
|
|
using Model;
|
|
|
|
using StubLib;
|
|
|
|
using StubLib;
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
|
@ -43,9 +42,9 @@ namespace API_LoL_Project.Controllers
|
|
|
|
return BadRequest("No chamions found with Id ");
|
|
|
|
return BadRequest("No chamions found with Id ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);;
|
|
|
|
_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));
|
|
|
|
var champions = await dataManager.GetItems(request.index, request.count, request.orderingPropertyName, request.descending);
|
|
|
|
IEnumerable<ChampionDTO> res = champions.Select(c => c.toDTO());
|
|
|
|
IEnumerable<ChampionDTO> res = champions.Select(c => c.ToDTO());
|
|
|
|
if (res.Count() >= 0 || res == null)
|
|
|
|
if (res.Count() <= 0 || res == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogWarning("No chamions found with Id");
|
|
|
|
_logger.LogWarning("No chamions found with Id");
|
|
|
|
return BadRequest("No chamions found with Id ");
|
|
|
|
return BadRequest("No chamions found with Id ");
|
|
|
@ -73,7 +72,7 @@ namespace API_LoL_Project.Controllers
|
|
|
|
var champion = await dataManager
|
|
|
|
var champion = await dataManager
|
|
|
|
.GetItemsByName(name, 0, await dataManager.GetNbItems());
|
|
|
|
.GetItemsByName(name, 0, await dataManager.GetNbItems());
|
|
|
|
_logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
|
|
|
|
_logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
|
|
|
|
ChampionDTO res = champion.First().toDTO();
|
|
|
|
ChampionDTO res = champion.First().ToDTO();
|
|
|
|
if (res == null)
|
|
|
|
if (res == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogWarning("No chamions found with {name}", name); ;
|
|
|
|
_logger.LogWarning("No chamions found with {name}", name); ;
|
|
|
@ -96,7 +95,7 @@ namespace API_LoL_Project.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var newChampion = value.toModel();
|
|
|
|
var newChampion = value.ToModel();
|
|
|
|
await dataManager.AddItem(newChampion);
|
|
|
|
await dataManager.AddItem(newChampion);
|
|
|
|
return CreatedAtAction(nameof(Get), newChampion) ;
|
|
|
|
return CreatedAtAction(nameof(Get), newChampion) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -118,7 +117,7 @@ namespace API_LoL_Project.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var champion = await dataManager
|
|
|
|
var champion = await dataManager
|
|
|
|
.GetItemsByName(name, 0, await dataManager.GetNbItems());
|
|
|
|
.GetItemsByName(name, 0, await dataManager.GetNbItems());
|
|
|
|
await dataManager.UpdateItem(champion.First(), value.toModel());
|
|
|
|
await dataManager.UpdateItem(champion.First(), value.ToModel());
|
|
|
|
return Ok();
|
|
|
|
return Ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception e)
|
|
|
|
catch(Exception e)
|
|
|
|