diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/API_LoL_Project.csproj b/EntityFramework_LoL/Sources/API_LoL_Project/API_LoL_Project.csproj
index 1df2c4a..6f0b5a0 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/API_LoL_Project.csproj
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/API_LoL_Project.csproj
@@ -22,6 +22,8 @@
+
+
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/ChampionsController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/ChampionsController.cs
index ce3fe29..3bf7f28 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/ChampionsController.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/ChampionsController.cs
@@ -1,16 +1,20 @@
-using API_LoL_Project.Mapper;
+using API_LoL_Project.Controllers.Response;
+using API_LoL_Project.Mapper;
using API_LoL_Project.Middleware;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
+using System.Collections.Generic;
+using System.Text.Json;
using System.Xml.Linq;
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace API_LoL_Project.Controllers
{
+ /*[Route("api/v{version:apiVersion}/[controller]")]*/
[Route("api/[controller]")]
+ /*[ApiVersion("1.0")]*/
[ApiController]
public class ChampionsController : ControllerBase
{
@@ -29,42 +33,58 @@ namespace API_LoL_Project.Controllers
- // GET: api/
+ // GET: api//getAllChampions
[HttpGet]
- public async Task>> Get([FromQuery] Request.PageRequest request)
+ public async Task>> Get([FromQuery] Request.PageRequest request)
{
try
{
var totalcount = await dataManager.GetNbItems();
- if (request.count + request.index > totalcount)
+ if (request.count * request.index >= totalcount)
{
- _logger.LogWarning("No chamions found with Id");
- return BadRequest("No chamions found with Id ");
+ _logger.LogError("To many object is asked the max is {totalcount} but the request is supérior of ", totalcount);
+ return BadRequest("To many object is asked the max is : " + totalcount);
}
- _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);;
- var champions = await dataManager.GetItems(request.index, request.count, request.orderingPropertyName, request.descending);
+
+ _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request); ;
+ var champions = await dataManager.GetItems(request.index, request.count, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
IEnumerable 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.LogError("No chamions found the total count is {totalcount} ", totalcount);
+ return BadRequest("No chamions found : totalcount is : " + totalcount);
}
- return Ok(res);
+
+ var respList = res.Select(r => new LolResponce
+ (
+ r,
+ new List
+ {
+ EndPointLink.To($"/api/[controller]/{r.Name}", "self"),
+ EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Get)}", "self"),
+ EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetChampionsImage)}", "self"),
+ EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetChampionsByName)}", "self"),
+ EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Post)}", "self","POST"),
+ EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"),
+ }
+ ));
+
+ var pageResponse = new PageResponse(respList, request.index, request.count, totalcount);
+
+ return Ok(pageResponse);
}
catch (Exception e)
{
+ _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message);
return BadRequest(e.Message);
}
-
-
}
-
- // GET api//5
- [HttpGet("{name}")]
- public async Task> GetChampionsByName(string name)
+ /*// GET api//5
+ [HttpGet("{id}")]
+ public async Task>> GetChampionsById(int name)
{
try
{
@@ -72,10 +92,11 @@ 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 res = champion.Select(c => c.toFullDTO());
+
if (res == null)
{
- _logger.LogWarning("No chamions found with {name}", name); ;
+ _logger.LogWarning("No chamions found with {name}", name); ;
return NotFound();
}
return Ok(res);
@@ -85,6 +106,79 @@ namespace API_LoL_Project.Controllers
{
return BadRequest(e.Message);
+ }
+ }*/
+
+ // GET: api//LargeImage
+ [HttpGet("image/{name}")]
+ public async Task> GetChampionsImage(string name)
+ {
+ try
+ {
+ var champion = await dataManager
+ .GetItemsByName(name, 0, await dataManager.GetNbItems());
+ _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
+ /* IEnumerable res = champion.Select(c => c.toFullDTO());//.First*/
+ ChampionFullDTO res = champion.First().toFullDTO();//.First
+
+ if (res == null)
+ {
+ _logger.LogWarning("No chamions found with {name}", name); ;
+ return NotFound();
+ }
+
+ return Ok(res.LargeImage);
+
+ }
+ catch (Exception e)
+ {
+ return BadRequest(e.Message);
+
+ }
+ }
+
+
+ // GET api//name
+ [HttpGet("{name}")]
+ public async Task>> GetChampionsByName(string name)
+ {
+ _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
+ try
+ {
+ var totalcount = await dataManager.GetNbItemsByName(name);
+ if (totalcount <= 0)
+ {
+ _logger.LogWarning("No chamions found with this name {name}", name); ;
+ return BadRequest("No chamions found with this name: " + name);
+ }
+
+ var champion = await dataManager.GetItemsByName(name, 0, totalcount);
+ /* IEnumerable res = champion.Select(c => c.toFullDTO());//.First*/
+ if (champion.Count() <= 0 || champion == null)
+ {
+ _logger.LogWarning("No chamions found with {name}", name); ;
+ return NotFound("No chamions found with" + name);
+ }
+ ChampionFullDTO res = champion.First().toFullDTO();//.First
+
+
+ var links = new List
+ {
+ 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(res, links);
+ return Ok(response);
+
+ }
+ catch (Exception e)
+ {
+
+ _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message);
+ return BadRequest("Somthing goes wrong caching the Champions controller : " + e.Message);
+
}
}
@@ -97,31 +191,46 @@ namespace API_LoL_Project.Controllers
{
var newChampion = value.ToModel();
await dataManager.AddItem(newChampion);
- return CreatedAtAction(nameof(Get), newChampion) ;
+ // can we check with a method
+ //var savedChampions = await dataManager.GetItemsByName(newChampion.name, 0, await dataManager.GetNbItems())
+ /*if (savedChampions.Count() >= 0 || res == null)
+ {
+ _logger.LogWarning("No chamions found ");
+ return BadRequest("No chamions found ");
+ }*/
+ _logger.LogInformation("Sucessfully saved Champions : " + newChampion.Name);
+
+ return CreatedAtAction(nameof(Get), newChampion);
}
catch (Exception e)
{
+ _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message);
return BadRequest(e.Message);
}
}
-
+ // should change for id cause model implementation use filteringbyName to getItemByNAme and it use substring
// PUT api//5
[HttpPut("{name}")]
public async Task Put(string name, [FromBody] ChampionDTO value)
{
-
-
try
{
+ _logger.LogInformation("Executing {Action} with name : {championName}", nameof(Put), name);
var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
+ if (champion == null)
+ {
+ _logger.LogError("No chamions found with {name} in the dataBase", name); ;
+ return NotFound();
+ }
await dataManager.UpdateItem(champion.First(), value.ToModel());
return Ok();
}
- catch(Exception e)
+ catch (Exception e)
{
+ _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message);
return BadRequest(e.Message);
}
}
@@ -132,20 +241,23 @@ namespace API_LoL_Project.Controllers
{
try
{
+ _logger.LogInformation("Executing {Action} with name : {championName}", nameof(Delete), name);
var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
if (champion != null) await dataManager.DeleteItem(champion.First());
else
{
+ _logger.LogWarning("No chamions found with {name}", name); ;
return NotFound();
}
return Ok();
}
catch (Exception e)
{
+ _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message);
return BadRequest(e.Message);
}
-
+
}
/* [HttpGet]
@@ -158,17 +270,48 @@ namespace API_LoL_Project.Controllers
}*/
[HttpGet("/{name}/skins")]
- public async Task> GetChampionsSkins(string name)
+ public async Task> GetChampionsSkins(string name)
{
+ _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsSkins), name);
var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems());
+ if (champions == null)
+ {
+ _logger.LogWarning("No chamions found with {name}", name); ;
+ return NotFound();
+ }
//skinsDTO
- IEnumerable res = champions.First().Skins;
-
+ IEnumerable res = champions.First().Skins.Select(c => c.ToDto());
+ if (res == null)
+ {
+ _logger.LogWarning("No skins found for {name}", name); ;
+ return NotFound();
+ }
return Ok(res);
}
- [HttpGet("/{name}/skills")]
- public async Task> GetChampionsSkills(string name)
+ /* [HttpGet("/{name}/skills")]
+ public async Task> GetChampionsSkills(string name)
+ {
+ _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsSkills), name);
+ var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems());
+ if (champions == null)
+ {
+ _logger.LogWarning("No chamions found with {name}", name); ;
+ return NotFound();
+ }
+ //skinsDTO
+ IEnumerable res = champions.First().Skills.to;
+ if (res == null)
+ {
+ _logger.LogWarning("No skins found for {name}", name); ;
+ return NotFound();
+ }
+
+ return Ok(res);
+ }*/
+
+ [HttpPost("/{name}/skills")]
+ public async Task>> AddChampionsSkills(string name)
{
var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems());
//SkillDTO
@@ -177,13 +320,14 @@ namespace API_LoL_Project.Controllers
return Ok(res);
}
- /*[HttpGet("/{name}/skins")]
- public async Task NbChampions()
+ // degradation du modèle cleitn ell est dédié au cliens
+ [HttpGet("/count")]
+ public async Task> NbChampions()
{
- var champions = await dataManager.GetItems(0, await dataManager.GetNbItems());
- IEnumerable res = champions.Select(c => c.toDTO());
- return Ok(res);
+ var nbChampions = await dataManager.GetNbItems();
+ return Ok(nbChampions);
+ }
- }*/
}
}
+
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Request/PageRequest.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Request/PageRequest.cs
index d4b5580..c4c464c 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Request/PageRequest.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Request/PageRequest.cs
@@ -3,8 +3,26 @@
public class PageRequest
{
public string? orderingPropertyName { get; set; } = null;
- public bool descending { get; set; } = false;
+ public bool? descending { get; set; } = false;
+ // const int maxPageSize = 50;
+ // public int PageNumber { get; set; } = 1;
+
public int index { get; set; } = 1;
public int count { get; set; } = 1;
+
+/*
+ //max lentght
+ private int _pageSize;
+ public int PageSize
+ {
+ get
+ {
+ return _pageSize;
+ }
+ set
+ {
+ _pageSize = (value > maxPageSize) ? maxPageSize : value;
+ }
+ }*/
}
}
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Response/EndPointLink.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Response/EndPointLink.cs
new file mode 100644
index 0000000..3ef451d
--- /dev/null
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Response/EndPointLink.cs
@@ -0,0 +1,22 @@
+namespace API_LoL_Project.Controllers.Response
+{
+ public class EndPointLink
+ {
+ public string Href { get; set; }
+ public string Rel { get; set; }
+ public string Method { get; set; }
+ public EndPointLink()
+ {
+ }
+ public EndPointLink(string href, string rel, string method)
+ {
+ Href = href;
+ Rel = rel;
+ Method = method;
+ }
+ public static EndPointLink To(string href, string rel = "self", string method = "GET")
+ {
+ return new EndPointLink { Href = href, Rel = rel, Method = method };
+ }
+ }
+}
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Response/PageResponse.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Response/PageResponse.cs
index f75a599..62a21bc 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Response/PageResponse.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/Response/PageResponse.cs
@@ -1,6 +1,22 @@
-namespace API_LoL_Project.Controllers.Response
+using API_LoL_Project.Middleware;
+
+namespace API_LoL_Project.Controllers.Response
{
- public class PageResponse
+ public class PageResponse
{
+ public IEnumerable> Data { get; set; }
+ public int Index { get; set; } = 1;
+ public int TotalCount { get; set; } = 1;
+ public int Count { get; set; } = 1;
+
+
+ public PageResponse(IEnumerable> data, int indexRequested, int countRequested, int totalCount)
+ {
+ this.Data = data;
+ this.Index = indexRequested;
+ this.TotalCount = totalCount;
+ this.Count = countRequested;
+ }
}
}
+
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RuneController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RuneController.cs
index f22363b..9ec17e0 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RuneController.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RuneController.cs
@@ -2,6 +2,8 @@
using Microsoft.AspNetCore.Mvc;
using Model;
using API_LoL_Project.Mapper;
+using API_LoL_Project.Controllers.Response;
+using API_LoL_Project.Middleware;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@@ -12,40 +14,71 @@ namespace API_LoL_Project.Controllers
[ApiController]
public class RuneController : ControllerBase
{
- /*public IRunesManager runesManager;
+ public IRunesManager dataManager;
// you should create a custom logger to be prety
private readonly ILogger _logger;
public RuneController(IDataManager dataManager, ILogger logger)
{
- this.runesManager = dataManager.RunesMgr;
+ this.dataManager = dataManager.RunesMgr;
this._logger = logger;
}
- *//*// GET: api/
+ // GET: api/
[HttpGet]
- public async Task> Get()
+ public async Task>> GetAllRunes([FromQuery] Request.PageRequest request)
{
try
{
- var runes = await runesManager.GetItems(0, await runesManager.GetNbItems());
+ var totalcount = await dataManager.GetNbItems();
+ if (request.count * request.index >= totalcount)
+ {
+ _logger.LogError("To many object is asked the max is {totalcount} but the request is supérior of ", totalcount);
+ return BadRequest("To many object is asked the max is : " + totalcount);
+ }
+
+ _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 res = runes.Select(c => c.toDTO());
- return Ok(res);
+ 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
+ (
+ r,
+ new List
+ {
+ EndPointLink.To($"/api/[controller]/{r.Name}", "self"),
+ 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"),
+ EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(GetAllRunes)}", "self","POST"),
+ EndPointLink.To($"/api/[controller]/{r.Name}/{nameof(Put)}", "self","PUT"),
+ }
+ ));
+
+ var pageResponse = new PageResponse(respList, request.index, request.count, totalcount);
+
+ return Ok(pageResponse);
}
catch (Exception e)
{
- _logger.LogInformation("About get at {e.message}", DateTime.UtcNow.ToLongTimeString());
+ _logger.LogError("Somthing goes wrong caching the Rune controller : " + e.Message);
return BadRequest(e.Message);
}
- }*//*
+ }
+
// GET: api/
- [HttpGet]
+ /* [HttpGet]
public async Task>> Get([FromQuery] Request.PageRequest request)
{
try
@@ -54,12 +87,12 @@ namespace API_LoL_Project.Controllers
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) ;
+ 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));
+
+ var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
IEnumerable res = runes.Select(c => c.toDTO());
if (res.Count() >= 0 || res == null)
{
@@ -77,9 +110,45 @@ namespace API_LoL_Project.Controllers
}
+*/
+
+ [HttpGet("{name}")]
+ public async Task>> 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();
+
+ if (res == null)
+ {
+ _logger.LogWarning("No runes found with {name}", name); ;
+ return NotFound();
+ }
+ var links = new List
+ {
+ 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(res, links);
+ return Ok(response);
- // GET api//5
+ }
+ catch (Exception e)
+ {
+
+ _logger.LogError("Somthing goes wrong caching the Champions controller : " + e.Message);
+ return BadRequest(e.Message);
+
+ }
+ }
+
+ /* // GET api//5
[HttpGet("{id}")]
public string Get(int id)
{
@@ -97,24 +166,10 @@ namespace API_LoL_Project.Controllers
}
- }
+ }*/
// POST api/
- [HttpPost]
- public void Post([FromBody] string value)
- {
- try
- {
- await dataManager.AddItem(value.toModel());
- return Ok();
- }
- catch ()
- {
- new HttpException(400, 'Cannot create rune')
- }
-
-
- }
+
// PUT api//5
[HttpPut("{id}")]
@@ -127,6 +182,6 @@ namespace API_LoL_Project.Controllers
[HttpDelete("{id}")]
public void Delete(int id)
{
- }*/
+ }
}
}
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RunePageController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RunePageController.cs
index 76a0d96..271d180 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RunePageController.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/RunePageController.cs
@@ -9,7 +9,7 @@ namespace API_LoL_Project.Controllers
[ApiController]
public class RunePageController : ControllerBase
{
-/* // GET: api/
+ /* // GET: api/
[HttpGet]
public async Task>> Get([FromQuery] Request.PageRequest request)
{
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkinController.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkinController.cs
index fa3ddfd..9f41870 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkinController.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Controllers/SkinController.cs
@@ -1,4 +1,6 @@
-using Microsoft.AspNetCore.Mvc;
+using DTO;
+using Microsoft.AspNetCore.Mvc;
+using Model;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@@ -8,13 +10,21 @@ namespace API_LoL_Project.Controllers
[ApiController]
public class SkinController : ControllerBase
{
- /* // GET: api/
+ /* public ISkinsManager dataManager;
+ private readonly ILogger _logger;
+ public SkinController(IDataManager dataManager, ILogger logger)
+ {
+ this.dataManager = dataManager.SkinsMgr;
+ this._logger = logger;
+ }
+
+ // GET: api/
[HttpGet]
public async Task>> 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);
@@ -23,7 +33,7 @@ namespace API_LoL_Project.Controllers
_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));
+ var runes = await dataManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
IEnumerable res = runes.Select(c => c.toDTO());
if (res.Count() >= 0 || res == null)
{
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/ChampionMapper.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/ChampionMapper.cs
index 15f2889..ab56601 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/ChampionMapper.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/ChampionMapper.cs
@@ -10,9 +10,10 @@ namespace API_LoL_Project.Mapper
{
if (item == null)
{
- var message = string.Format("Champion with name = {} nhhoddt found", item.Name);
+ var message = string.Format("Champion cannot be empty");
/*throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));
*/
+ throw new Exception(message);
}
return new ChampionDTO() {
Name = item.Name,
@@ -35,17 +36,19 @@ namespace API_LoL_Project.Mapper
{
if (item == null)
{
- var message = string.Format("Champion with name = {} nhhoddt found", item.Name);
+ var message = string.Format("Champion with name = {} not found", item.Name);
/*throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));
*/
+ throw new Exception(message);
+
}
return new ChampionFullDTO()
{
Name = item.Name,
Bio = item.Bio,
skills = item.Skills,
- skins = item.Skins,
- LargeImage = item.Image.Base64
+ skins = item.Skins.Select(i => i.ToDto()),
+ LargeImage = item.Image.ToDTO()
};
@@ -56,9 +59,12 @@ namespace API_LoL_Project.Mapper
{
if (dto == null)
{
- var message = string.Format("Champion with name = {} nhhoddt found", dto.Name);
+ var message = string.Format("Champion cannot be empty");
/*throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));
- */}
+ */
+ throw new Exception(message);
+
+ }
return new(dto.Name);
}
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/ImageMappeur.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/ImageMappeur.cs
new file mode 100644
index 0000000..31f13ab
--- /dev/null
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/ImageMappeur.cs
@@ -0,0 +1,23 @@
+using DTO;
+using Model;
+
+namespace API_LoL_Project.Mapper
+{
+ public static class ImageMappeur
+ {
+ public static ImageDTO ToDTO(this LargeImage item)
+ {
+ if (item == null)
+ {
+ var message = string.Format("Image cannot be empty");
+ /*throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));
+ */
+ }
+ return new ImageDTO()
+ {
+ base64 = item.Base64
+ };
+ }
+
+ }
+}
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/RuneMapper.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/RuneMapper.cs
index 8c6d64a..e23de36 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/RuneMapper.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/RuneMapper.cs
@@ -29,3 +29,5 @@
}
}
}
+
+
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/SkinMapper.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/SkinMapper.cs
index e658fc3..f186858 100644
--- a/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/SkinMapper.cs
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Mapper/SkinMapper.cs
@@ -8,6 +8,23 @@ namespace API_LoL_Project.Mapper
{
+ public static Skin ToModel(this SkinEntity entity)
+ {
+ throw new NotImplementedException();
+
+ }
+ public static SkinDto ToDto(this Skin item)
+ {
+ return new SkinDto()
+ {
+ Name = item.Name,
+ Description = item.Description,
+ Icon = item.Icon,
+ Price = item.Price
+ };
+
+ }
+
}
}
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Middleware/HateosMiddleware.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Middleware/HateosMiddleware.cs
new file mode 100644
index 0000000..7207f72
--- /dev/null
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Middleware/HateosMiddleware.cs
@@ -0,0 +1,7 @@
+namespace API_LoL_Project.Middleware
+{
+ public class HateosMiddleware
+ {
+
+ }
+}
diff --git a/EntityFramework_LoL/Sources/API_LoL_Project/Middleware/LolResponce.cs b/EntityFramework_LoL/Sources/API_LoL_Project/Middleware/LolResponce.cs
new file mode 100644
index 0000000..22b7703
--- /dev/null
+++ b/EntityFramework_LoL/Sources/API_LoL_Project/Middleware/LolResponce.cs
@@ -0,0 +1,18 @@
+using API_LoL_Project.Controllers.Response;
+using System.Net;
+
+namespace API_LoL_Project.Middleware
+{
+ public class LolResponce
+ {
+ public T Data { get; set; }
+ public List Links { get; set; } = null;
+
+
+ public LolResponce(T data , List? links)
+ {
+ this.Data = data;
+ this.Links = links;
+ }
+ }
+}
diff --git a/EntityFramework_LoL/Sources/DTO/ChampionDTO.cs b/EntityFramework_LoL/Sources/DTO/ChampionDTO.cs
index 0f77a48..e0b4a1a 100644
--- a/EntityFramework_LoL/Sources/DTO/ChampionDTO.cs
+++ b/EntityFramework_LoL/Sources/DTO/ChampionDTO.cs
@@ -1,24 +1,31 @@
-using Model;
-using System.Buffers.Text;
-
+using Model;
+using System.Collections.ObjectModel;
+using System.ComponentModel.DataAnnotations;
+
namespace DTO
{
public class ChampionDTO
{
public string Name { get; set; }
public string Bio { get; set; }
+ public string Icon { get; set; }
+
/*public string Icon { get; set; }
*/
- }
+ }
public class ChampionFullDTO
{
+ /*[Required(ErrorMessage = "Name is required")]
+ [StringLength(60, ErrorMessage = "Name can't be longer than 60 characters")]*/
public string Name { get; set; }
public string Bio { get; set; }
- public string Characteristics { get; set; }
- public string LargeImage { get; set; }
+ public ReadOnlyDictionary Characteristics { get; set; }
+ public ImageDTO LargeImage { get; set; }
- public IEnumerable skins { get; set; }
+ public IEnumerable skins { get; set; }
public IEnumerable skills { get; set; }
}
+
+
}
\ No newline at end of file
diff --git a/EntityFramework_LoL/Sources/DTO/ImageDTO.cs b/EntityFramework_LoL/Sources/DTO/ImageDTO.cs
new file mode 100644
index 0000000..3b5cec1
--- /dev/null
+++ b/EntityFramework_LoL/Sources/DTO/ImageDTO.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTO
+{
+ public class ImageDTO
+ {
+ public string base64 { get; set; }
+ }
+}
diff --git a/EntityFramework_LoL/Sources/DTO/RuneDTO.cs b/EntityFramework_LoL/Sources/DTO/RuneDTO.cs
index f0a5d4f..64b8989 100644
--- a/EntityFramework_LoL/Sources/DTO/RuneDTO.cs
+++ b/EntityFramework_LoL/Sources/DTO/RuneDTO.cs
@@ -14,9 +14,9 @@ namespace DTO
public string Description { get; set; }
- public RuneFamily Family { get; set; }
+ public RuneFamily Family { get; set; }
- public string Icon { get; set; }
+ public string Icon { get; set; }
public LargeImage Image { get; set; }
}
diff --git a/EntityFramework_LoL/Sources/DTO/SkillDto.cs b/EntityFramework_LoL/Sources/DTO/SkillDto.cs
new file mode 100644
index 0000000..2b7f006
--- /dev/null
+++ b/EntityFramework_LoL/Sources/DTO/SkillDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTO
+{
+ public class SkillDto
+ {
+ public string Name { get; set; }
+ public string Description { get; set; }
+ }
+}
diff --git a/EntityFramework_LoL/Sources/DTO/SkinDto.cs b/EntityFramework_LoL/Sources/DTO/SkinDto.cs
new file mode 100644
index 0000000..2c3962b
--- /dev/null
+++ b/EntityFramework_LoL/Sources/DTO/SkinDto.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTO
+{
+ public class SkinDto
+ {
+ public string Name { get; set; }
+ public string Description { get; set; }
+ public string Icon { get; set; }
+ public float Price { get; set; }
+
+ }
+}
diff --git a/EntityFramework_LoL/Sources/LeagueOfLegends.sln b/EntityFramework_LoL/Sources/LeagueOfLegends.sln
index 8f1d4ea..bb6ec63 100644
--- a/EntityFramework_LoL/Sources/LeagueOfLegends.sln
+++ b/EntityFramework_LoL/Sources/LeagueOfLegends.sln
@@ -26,8 +26,11 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test_Api", "Test_Api\Test_Api.csproj", "{C35C38F6-5774-4562-BD00-C81BCE13A260}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}"
+<<<<<<< HEAD
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityMappers", "EntityMappers\EntityMappers.csproj", "{3A70A719-4F42-4CC3-846A-53437F3B4CC5}"
+=======
+>>>>>>> david_next_step
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution