feat + refactor : ajout du contrôleur des chapitres + création d'unité de centralisation des requêtes (~ unité de travail)
continuous-integration/drone/push Build is passing Details

API
Damien NORTIER 1 year ago
parent 26d1ba9360
commit 9ccf950f7c

@ -10,17 +10,15 @@ using Microsoft.AspNetCore.Http.HttpResults;
namespace WebApi.Controllers
{
[ApiController]
[Route("api/v[version]/")]
public class AdministratorController : ControllerBase
{
private IAdministratorManager<AdministratorDto> mgr;
private Unit unity;
private readonly Logger<AdministratorController> logger;
public AdministratorController(MyDbContext dbContext, Logger<AdministratorController> logger)
public AdministratorController(Unit unit, Logger<AdministratorController> logger)
{
mgr = new AdministratorServiceManager(dbContext);
this.unity = unit;
this.logger = logger;
}
@ -42,9 +40,9 @@ namespace WebApi.Controllers
/// </returns>
public async Task<IActionResult> PostAdministrator(AdministratorDto administrator)
{
int count = mgr.getNbElements(); // count : number of elements before opperation
var tmp = await mgr.addAdmin(administrator); // tmp : administrator recieve by the addAdmin method
if (mgr.getNbElements() == count) // <=> not added
int count = unity.getNbAdmins(); // count : number of elements before opperation
var tmp = await unity.addAdmin(administrator); // tmp : administrator recieve by the addAdmin method
if (unity.getNbAdmins() == count) // <=> not added
{
if(tmp.Username == administrator.Username)
{
@ -73,7 +71,7 @@ namespace WebApi.Controllers
else
{
// the administrator may be added but we do not recieved him
if (mgr.getAdministratorByUsername(administrator.Username) != null)
if (unity.getAdministratorByUsername(administrator.Username) != null)
{
// he is added
logger.LogError(message: $"administrator added but not recieved");
@ -83,7 +81,7 @@ namespace WebApi.Controllers
{
// he is not added
logger.LogCritical(message: "administrator that we wanted to add not added\nand we have added another one");
if (mgr.getAdministratorByUsername(administrator.Username) == null) // <=> not added
if (unity.getAdministratorByUsername(administrator.Username) == null) // <=> not added
return StatusCode(500);
}
}
@ -105,14 +103,14 @@ namespace WebApi.Controllers
///
/// return content :
/// a tuple of the number of page and
/// all T element in the database for
/// all administrators in the database for
/// the page nb if status code = 200
/// the number of page for count element if status code = 204
/// nothing if status code = 400
/// </returns>
public async Task<IActionResult> GetSomeAdministrators(int page, int count = 10, AdministratorOrderCriteria orderCriteria = AdministratorOrderCriteria.ById)
{
var tmp = await mgr.getAdministrators(page, count, orderCriteria);
var tmp = await unity.getAdministrators(page, count, orderCriteria);
if (tmp.administrators == null)
{
logger.LogInformation(message: "get admin : bad request (page or/and count incorrect)");
@ -120,7 +118,7 @@ namespace WebApi.Controllers
}
else if (tmp.administrators.Count() == 0)
{
logger.LogWarning(message: $"get admin : no content. number of element : {mgr.getNbElements()}, page wanted : {page}, number of elements in a page : {count}");
logger.LogWarning(message: $"get admin : no content. number of element : {unity.getNbAdmins()}, page wanted : {page}, number of elements in a page : {count}");
return NoContent();
}
else
@ -159,13 +157,13 @@ namespace WebApi.Controllers
logger.LogError("want to delete an administrator with an id less than 0");
return BadRequest();
}
int count = mgr.getNbElements(); // count : number of elements before opperation
var tmp = await mgr.removeAdmin(id);
int count = unity.getNbAdmins(); // count : number of elements before opperation
var tmp = await unity.removeAdmin(id);
if (tmp == null) // we don't recieve the administrator
{
if(mgr.getNbElements() == count) // he is not deleted
if(unity.getNbAdmins() == count) // he is not deleted
{
if (mgr.getAdministrator(id) != null)
if (unity.getAdministrator(id) != null)
{
logger.LogCritical(message: "remove administrator fail : administrator not removed and not recieved");
return StatusCode(500);
@ -178,7 +176,7 @@ namespace WebApi.Controllers
}
else // he may be deleted
{
if (mgr.getAdministrator(id) == null) // he must be deleted
if (unity.getAdministrator(id) == null) // he must be deleted
{
logger.LogError(message: "administrator removed but not returned");
return NoContent();
@ -190,7 +188,7 @@ namespace WebApi.Controllers
}
}
}
if(mgr.getNbElements() == count)
if(unity.getNbAdmins() == count)
{
// <=> we have recieved an administrator which should be deleted
// but since we have the same number of administrator than
@ -222,16 +220,16 @@ namespace WebApi.Controllers
/// </returns>
public async Task<IActionResult> PutAdministrator(int id, AdministratorDto administrator)
{
var tmp = await mgr.getAdministratorByUsername(administrator.Username);
var tmp = await unity.getAdministratorByUsername(administrator.Username);
if (tmp != null)
{
logger.LogTrace(message: "Want to modify into an administrator who already exist");
return StatusCode(StatusCodes.Status208AlreadyReported, tmp);
}
tmp = await mgr.updateAdministrator(id, administrator);
tmp = await unity.updateAdministrator(id, administrator);
if(tmp == null)
{
tmp = await mgr.getAdministrator(id);
tmp = await unity.getAdministrator(id);
if (tmp == null) // Ok, it don't exist
{
logger.LogWarning(message: "Want to modify an administrator who don't exist");
@ -261,7 +259,7 @@ namespace WebApi.Controllers
}
else // he haven't changed
{
var tmp2 = (await mgr.getAdministratorByUsername(administrator.Username));
var tmp2 = (await unity.getAdministratorByUsername(administrator.Username));
if(tmp2 != null) // it change another administrator
logger.LogCritical(message: "administrator should have changed but he haven't. Instead, another one changed");
else // nothing have changed
@ -271,7 +269,7 @@ namespace WebApi.Controllers
}
else // we recieve another one
{
var tmp2 = await mgr.getAdministrator(id);
var tmp2 = await unity.getAdministrator(id);
if (tmp2 == null)
{ // ok, he d'ont exist.
logger.LogError(message: "Want to modify an administrator who don't exist but recieved a random one");

@ -1,6 +0,0 @@
namespace WebApi.Controllers
{
public class AnswerController
{
}
}

@ -1,6 +1,304 @@
namespace WebApi.Controllers
using DTOs;
using Microsoft.AspNetCore.Mvc;
using OrderCriterias;
namespace WebApi.Controllers
{
public class ChapterController
public class ChapterController : ControllerBase
{
private Unit unity;
private readonly Logger<ChapterController> logger;
public ChapterController(Unit unit, Logger<ChapterController> logger)
{
this.unity = unit;
this.logger = logger;
}
/// <summary>
/// add a chapter
/// </summary>
/// <param name="chapter">the chapter to add</param>
/// <returns>
/// status code :
/// 200 if the chapter is added
/// 202 if the chapter is added
/// 208 if the chapter was already in the database
/// 500 if there was an internal error that doesn't allow to continue
/// return content :
/// no content when status code = 200
/// chapter added when status code = 202
/// chapter already in the database that equals the one we wanted to add when status code = 208
/// no content when status code = 500
/// </returns>
public async Task<IActionResult> PostChapter(ChapterDto chapter)
{
int count = unity.getNbChapters(); // count : number of elements before opperation
var tmp = await unity.addChapter(chapter); // tmp : chapter recieve by the addChapter method
if (unity.getNbChapters() == count) // <=> not added
{
if (tmp.Name == chapter.Name)
{
// it was already in the database
logger.LogInformation(message: $"want to add a chapter already in the database : {tmp.ToString()}");
return StatusCode(208, tmp);
}
else
{
// we recieve a chapter already in the database
// that should be equal to the chapter that we
// wanted to add but it isn't
logger.LogCritical(message: "controller's add fail (already in the database) but\nchapter" +
$" recieve isn't the same as the one we wanted to add.\n" +
$"Chapter recieve : {tmp.ToString()}\nchapter to add : {chapter.ToString()}");
return StatusCode(500);
}
}
// added
if (tmp.Name == chapter.Name)
{
logger.LogTrace(message: $"chapter added : {tmp.ToString()}");
// the chapter has been added and we recieved him
return StatusCode(202, tmp);
}
else
{
// the chapter may be added but we do not recieved him
if (unity.getChapter(chapter.Name) != null)
{
// he is added
logger.LogError(message: $"chapter added but not recieved");
return Ok(); // not 202 to make a difference between 2 cases
}
else
{
// he is not added
logger.LogCritical(message: "chapter that we wanted to add not added\nand we have added another one");
if (unity.getChapter(chapter.Name) == null) // <=> not added
return StatusCode(500);
}
}
logger.LogError(message: "this case should not append");
return StatusCode(500);
}
/// <summary>
/// get a part of all chapters
/// </summary>
/// <param name="page">the actual page</param>
/// <param name="count">number of T element in a page</param>
/// <param name="orderCriteria">the order criteria</param>
/// <returns>
/// status code :
/// 200 if we got a set
/// 204 if we got an empty set
/// 400 if we got nothing
///
/// return content :
/// a tuple of the number of page and
/// all chapters in the database for
/// the page nb if status code = 200
/// the number of page for count element if status code = 204
/// nothing if status code = 400
/// </returns>
public async Task<IActionResult> GetSomeChapters(int page, int count = 10, ChapterOrderCriteria orderCriteria = ChapterOrderCriteria.ById)
{
var tmp = await unity.getChapters(page, count, orderCriteria);
if (tmp.chapters == null)
{
logger.LogInformation(message: "get chapter : bad request (page or/and count incorrect)");
return BadRequest(tmp.nbPages);
}
else if (tmp.chapters.Count() == 0)
{
logger.LogWarning(message: $"get chapter : no content. number of element : {unity.getNbChapters()}, page wanted : {page}, number of elements in a page : {count}");
return NoContent();
}
else
{
logger.LogTrace(message: $"get chapters : page = {page}, count = {count}, order criteria = {orderCriteria switch
{
ChapterOrderCriteria.ById => "byId",
ChapterOrderCriteria.ByName => "byName",
_ => "none"
}}");
return Ok(tmp);
}
}
/// <summary>
/// delete a chapter
/// </summary>
/// <param name="id">the id of the chapter to delete</param>
/// <returns>
/// <returns>
/// status code :
/// 200 if the chapter is removed
/// 204 if the chapter is removed
/// 400 if the id is incorrect
/// 500 if there was an internal error that doesn't allow to continue
/// return content :
/// aministrator deleted when status code = 200
/// no content when status code = 204
/// no content when status code = 400
/// no content when status code = 500
/// </returns>
public async Task<IActionResult> DeleteChapter(int id)
{
if (id < 0)
{
logger.LogError("want to delete a chapter with an id less than 0");
return BadRequest();
}
int count = unity.getNbChapters(); // count : number of elements before opperation
var tmp = await unity.removeChapter(id);
if (tmp == null) // we don't recieve the chapter
{
if (unity.getNbChapters() == count) // he is not deleted
{
if (unity.getChapter(id) != null)
{
logger.LogCritical(message: "remove chapter fail : chapter not removed and not recieved");
return StatusCode(500);
}
else
{
logger.LogInformation(message: "trying to remove a chapter with an id who don't exist");
return BadRequest();
}
}
else // he may be deleted
{
if (unity.getChapter(id) == null) // he must be deleted
{
logger.LogError(message: "chapter removed but not returned");
return NoContent();
}
else // he is not deleted
{
logger.LogCritical(message: "remove chapter fail : chapter to remove not remove\ninstead, anotherone is deleted and we recieved nothing");
return StatusCode(500);
}
}
}
if (unity.getNbChapters() == count)
{
// <=> we have recieved a chapter which should be deleted
// but since we have the same number of chapter than
// before deletion, it isn't deleted
logger.LogCritical(message: $"chapter \"{tmp.ToString()}\"should be delete but it isn't");
return StatusCode(500);
}
logger.LogTrace(message: $"chapter removed {tmp.ToString()}");
return Ok(tmp);
}
/// <summary>
/// update a chapter
/// </summary>
/// <param name="id">id of the chapter to update</param>
/// <param name="chapter">a chapter who contains all properties to change</param>
/// <returns>
/// status code :
/// 200 if the chapter is modified
/// 204 if we wanted to modify a chapter who don't exist
/// 208 if the new username of the chapter is already used
/// 500 if there was an internal error that doesn't allow to continue
///
/// return content :
/// the chapter modified when status code = 200
/// nothing when status code = 204
/// the chapter that already have the username when status code = 208
/// nothing when status code = 500
/// </returns>
public async Task<IActionResult> PutChapter(int id, ChapterDto chapter)
{
var tmp = await unity.getChapter(chapter.Name);
if (tmp != null)
{
logger.LogTrace(message: "Want to modify into a chapter who already exist");
return StatusCode(StatusCodes.Status208AlreadyReported, tmp);
}
tmp = await unity.updateChapter(id, chapter.Name);
if (tmp == null)
{
tmp = await unity.getChapter(id);
if (tmp == null) // Ok, it don't exist
{
logger.LogWarning(message: "Want to modify a chapter who don't exist");
return NoContent();
}
else
{
if (tmp.Name == chapter.Name)
{
logger.LogError(message: "Chapter changed but not recieved");
return Ok(tmp);
}
else
{
logger.LogCritical(message: "chapter haven't changed and we recieved nothing");
return StatusCode(500);
}
}
}
else if (tmp.Id == id) // we recieve him
{
if (tmp.Name == chapter.Name) // he is changed
{
logger.LogTrace(message: $"chapter with id {id} modified in {chapter.ToString()}");
return Ok(tmp);
}
else // he haven't changed
{
var tmp2 = (await unity.getChapter(chapter.Name));
if (tmp2 != null) // it change another chapter
logger.LogCritical(message: "chapter should have changed but he haven't. Instead, another one changed");
else // nothing have changed
logger.LogCritical(message: "chapter should have changed but he haven't and we recieved him");
return StatusCode(500);
}
}
else // we recieve another one
{
var tmp2 = await unity.getChapter(id);
if (tmp2 == null)
{ // ok, he d'ont exist.
logger.LogError(message: "Want to modify a chapter who don't exist but recieved a random one");
return NoContent();
}
else if (tmp2.Name == chapter.Name)
{
logger.LogError(message: $"chapter modified but recieved a random one");
return Ok(tmp2);
}
else
{
logger.LogCritical(message: "chapter that we wanted to modify not modified");
return StatusCode(500);
}
}
}
/// <summary>
/// get a chapter
/// </summary>
/// <param name="name">the name of the chapter</param>
/// <returns>
/// status code :
/// 200 when we got a chapter
/// 204 when we got null
///
/// return content :
/// the chapter that correspond to the name when status code = 200
/// nothing when status code 204
/// </returns>
public async Task<IActionResult> GetChapter(string name)
{
var tmp = await unity.getChapter(name);
if(tmp == null) return NoContent();
return Ok(tmp);
}
}
}

@ -1,6 +1,7 @@
using DbConnectionLibrairie;
using DTOs;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using OrderCriterias;
namespace WebApi.Controllers
@ -9,7 +10,6 @@ namespace WebApi.Controllers
{
// all secondary controllers
private AdministratorController administratorController;
private AnswerController answerController;
private ChapterController chapterController;
private LobbyController lobbyController;
private PlayerController playerController;
@ -18,19 +18,18 @@ namespace WebApi.Controllers
public FrontController(
MyDbContext dbContext,
Logger<AdministratorController> logAdmin,
Logger<AnswerController> logAnswer,
Logger<ChapterController> logChapter,
Logger<LobbyController> logLobby,
Logger<PlayerController> logPlayer,
Logger<QuestionController> logQuestion
)
{
administratorController = new AdministratorController(dbContext, logAdmin);
answerController = new AnswerController(dbContext, logAnswer);
chapterController = new ChapterController(dbContext, logChapter);
lobbyController = new LobbyController(dbContext, logLobby);
playerController = new PlayerController(dbContext, logPlayer);
questionController = new QuestionController(dbContext, logQuestion);
var unity = new Unit(dbContext);
administratorController = new AdministratorController(unity, logAdmin);
chapterController = new ChapterController(unity, logChapter);
lobbyController = new LobbyController(unity, logLobby);
playerController = new PlayerController(unity, logPlayer);
questionController = new QuestionController(unity, logQuestion);
}
/// <summary>
@ -71,7 +70,7 @@ namespace WebApi.Controllers
///
/// return content :
/// a tuple of the number of page and
/// all T element in the database for
/// all administrators in the database for
/// the page nb if status code = 200
/// the number of page for count element if status code = 204
/// nothing if status code = 400
@ -136,5 +135,126 @@ namespace WebApi.Controllers
=> await administratorController.PutAdministrator(id, administrator);
/// <summary>
/// add a chapter
/// </summary>
/// <param name="chapter">the chapter to add</param>
/// <returns>
/// status code :
/// 200 if the chapter is added
/// 202 if the chapter is added
/// 208 if the chapter was already in the database
/// 500 if there was an internal error that doesn't allow to continue
/// return content :
/// no content when status code = 200
/// chapter added when status code = 202
/// chapter already in the database that equals the one we wanted to add when status code = 208
/// no content when status code = 500
/// </returns>
[HttpPost("add/chapter")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status202Accepted)]
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> PostChapter([FromBody] ChapterDto chapter)
=> await chapterController.PostChapter(chapter);
/// <summary>
/// get a part of all chapters
/// </summary>
/// <param name="page">the actual page</param>
/// <param name="count">number of T element in a page</param>
/// <param name="orderCriteria">the order criteria</param>
/// <returns>
/// status code :
/// 200 if we got a set
/// 204 if we got an empty set
/// 400 if we got nothing
///
/// return content :
/// a tuple of the number of page and
/// all chapters in the database for
/// the page nb if status code = 200
/// the number of page for count element if status code = 204
/// nothing if status code = 400
/// </returns>
[HttpGet("all/chapter")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> GetSomeChapters([FromQuery] int page, int count = 10, ChapterOrderCriteria orderCriteria = ChapterOrderCriteria.ById)
=> await chapterController.GetSomeChapters(page, count, orderCriteria);
/// <summary>
/// delete a chapter
/// </summary>
/// <param name="id">the id of the chapter to delete</param>
/// <returns>
/// <returns>
/// status code :
/// 200 if the chapter is removed
/// 204 if the chapter is removed
/// 400 if the id is incorrect
/// 500 if there was an internal error that doesn't allow to continue
/// return content :
/// aministrator deleted when status code = 200
/// no content when status code = 204
/// no content when status code = 400
/// no content when status code = 500
/// </returns>
[HttpDelete("delete/chapter")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> DeleteChapter([FromQuery] int id)
=> await chapterController.DeleteChapter(id);
/// <summary>
/// update a chapter
/// </summary>
/// <param name="id">id of the chapter to update</param>
/// <param name="chapter">a chapter who contains all properties to change</param>
/// <returns>
/// status code :
/// 200 if the chapter is modified
/// 204 if we wanted to modify a chapter who don't exist
/// 208 if the new username of the chapter is already used
/// 500 if there was an internal error that doesn't allow to continue
///
/// return content :
/// the chapter modified when status code = 200
/// nothing when status code = 204
/// the chapter that already have the username when status code = 208
/// nothing when status code = 500
/// </returns>
[HttpPut("update/chapter")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> PutChapter([FromQuery] int id, [FromBody] ChapterDto chapter)
=> await chapterController.PutChapter(id, chapter);
/// <summary>
/// get a chapter
/// </summary>
/// <param name="name">the name of the chapter</param>
/// <returns>
/// status code :
/// 200 when we got a chapter
/// 204 when we got null
///
/// return content :
/// the chapter that correspond to the name when status code = 200
/// nothing when status code 204
/// </returns>
[HttpGet("chapters/name")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> GetChapter(string name)
=> await chapterController.GetChapter(name);
}
}

@ -0,0 +1,293 @@
using DbConnectionLibrairie;
using DTOs;
using ManagerInterfaces;
using OrderCriterias;
using ServiceManagers;
namespace WebApi
{
/// <summary>
/// just an interface between service managers and controllers
/// which contains all service managers methods who just calls
/// methods of service managers (we don't care about awaiting)
/// </summary>
public class Unit : IAdministratorManager<AdministratorDto>, IAnswerManager<AnswerDto>, IChapterManager<ChapterDto>, ILobbyManager<LobbyDto>, IPlayerManager<PlayerDto>, IQuestionManager<QuestionDto>
{
public IAdministratorManager<AdministratorDto> AdministratorManager { get; set; }
public IAnswerManager<AnswerDto> AnswerManager { get; set; }
public IChapterManager<ChapterDto> ChapterManager { get; private set; }
public ILobbyManager<LobbyDto> LobbyManager { get; private set; }
public IPlayerManager<PlayerDto> PlayerManager { get; private set; }
public IQuestionManager<QuestionDto> QuestionManager { get; private set; }
public Unit(MyDbContext dbContext)
{
AdministratorManager = new AdministratorServiceManager(dbContext);
AnswerManager = new AnswerServiceManager(dbContext);
ChapterManager = new ChapterServiceManager(dbContext);
LobbyManager = new LobbyServiceManager(dbContext);
PlayerManager = new PlayerServiceManager(dbContext);
QuestionManager = new QuestionServiceManager(dbContext);
}
public int getNbAdmins()
{
return AdministratorManager.getNbAdmins();
}
public Task<AdministratorDto> addAdmin(AdministratorDto admin)
{
return AdministratorManager.addAdmin(admin);
}
public Task<AdministratorDto?> removeAdmin(AdministratorDto admin)
{
return AdministratorManager.removeAdmin(admin);
}
public Task<AdministratorDto?> removeAdmin(int id)
{
return AdministratorManager.removeAdmin(id);
}
public Task<(int nbPages, IEnumerable<AdministratorDto>? administrators)> getAdministrators(int page, int count, AdministratorOrderCriteria orderCriteria = AdministratorOrderCriteria.ById)
{
return AdministratorManager.getAdministrators(page, count, orderCriteria);
}
public Task<AdministratorDto?> getAdministrator(int id)
{
return AdministratorManager.getAdministrator(id);
}
public Task<AdministratorDto?> getAdministratorByUsername(string username)
{
return AdministratorManager.getAdministratorByUsername(username);
}
public Task<bool> setPassword(string username, string newHashedPassword)
{
return AdministratorManager.setPassword(username, newHashedPassword);
}
public Task<AdministratorDto?> updateAdministrator(int id, AdministratorDto admin)
{
return AdministratorManager.updateAdministrator(id, admin);
}
public int getNbAnswers()
{
return AnswerManager.getNbAnswers();
}
public Task<(int nbPages, IEnumerable<AnswerDto>? answers)> getAnswers(int nb, int count, AnswerOrderCriteria orderCriteria = AnswerOrderCriteria.ById)
{
return AnswerManager.getAnswers(nb, count, orderCriteria);
}
public Task<IEnumerable<AnswerDto>?> getAnswers(string content)
{
return AnswerManager.getAnswers(content);
}
public Task<IEnumerable<AnswerDto>?> getAnswersByIdQuestion(int id)
{
return AnswerManager.getAnswersByIdQuestion(id);
}
public Task<AnswerDto?> updateAnswer(int id, AnswerDto answer)
{
return AnswerManager.updateAnswer(id, answer);
}
public Task<AnswerDto?> removeAnswer(int id)
{
return AnswerManager.removeAnswer(id);
}
public Task<AnswerDto?> removeAnswer(AnswerDto answer)
{
return AnswerManager.removeAnswer(answer);
}
public Task<AnswerDto> addAnswer(AnswerDto answer)
{
return AnswerManager.addAnswer(answer);
}
public Task<AnswerDto?> getAnswer(int id)
{
return AnswerManager.getAnswer(id);
}
public int getNbChapters()
{
return ChapterManager.getNbChapters();
}
public Task<ChapterDto> addChapter(ChapterDto chapter)
{
return ChapterManager.addChapter(chapter);
}
public Task<ChapterDto?> removeChapter(ChapterDto chapter)
{
return ChapterManager.removeChapter(chapter);
}
public Task<ChapterDto?> removeChapter(int id)
{
return ChapterManager.removeChapter(id);
}
public Task<ChapterDto?> getChapter(int id)
{
return ChapterManager.getChapter(id);
}
public Task<ChapterDto?> getChapter(string name)
{
return ChapterManager.getChapter(name);
}
public Task<(int nbPages, IEnumerable<ChapterDto>? chapters)> getChapters(int nb, int count, ChapterOrderCriteria orderCriteria = ChapterOrderCriteria.ById)
{
return ChapterManager.getChapters(nb, count, orderCriteria);
}
public Task<ChapterDto?> updateChapter(int id, string newName)
{
return ChapterManager.updateChapter(id, newName);
}
public int getNbLobbies()
{
return LobbyManager.getNbLobbies();
}
public Task<LobbyDto> addLobby(LobbyDto lobby)
{
return LobbyManager.addLobby(lobby);
}
public Task<LobbyDto?> removeLobby(LobbyDto lobby)
{
return LobbyManager.removeLobby(lobby);
}
public Task<LobbyDto?> removeLobby(int id)
{
return LobbyManager.removeLobby(id);
}
public Task<(int nbPages, IEnumerable<LobbyDto>? lobbies)> getLobbies(int nb, int count, LobbyOrderCriteria orderCriteria = LobbyOrderCriteria.ById)
{
return LobbyManager.getLobbies(nb, count, orderCriteria);
}
public Task<LobbyDto?> getLobby(int id)
{
return LobbyManager.getLobby(id);
}
public int getNbPlayers()
{
return PlayerManager.getNbPlayers();
}
public Task<PlayerDto> addPlayer(PlayerDto player)
{
return PlayerManager.addPlayer(player);
}
public Task<PlayerDto?> removePlayer(PlayerDto player)
{
return PlayerManager.removePlayer(player);
}
public Task<PlayerDto?> removePlayer(int id)
{
return PlayerManager.removePlayer(id);
}
public Task<(int nbPages, IEnumerable<PlayerDto>? players)> getPlayers(int nb, int count, PlayerOrderCriteria orderCriteria = PlayerOrderCriteria.ById)
{
return PlayerManager.getPlayers(nb, count, orderCriteria);
}
public Task<PlayerDto?> getPlayer(int id)
{
return PlayerManager.getPlayer(id);
}
public Task<PlayerDto?> getPlayer(string nickname)
{
return PlayerManager.getPlayer(nickname);
}
public Task<IEnumerable<PlayerDto>?> getPlayersInALobby(int idLobby)
{
return PlayerManager.getPlayersInALobby(idLobby);
}
public Task<int?> getMaxScorePlayer(int id, int idChapter)
{
return PlayerManager.getMaxScorePlayer(id, idChapter);
}
public Task<int?> getMaxScorePlayer(int id)
{
return PlayerManager.getMaxScorePlayer(id);
}
public int getNbQuestions()
{
return QuestionManager.getNbQuestions();
}
public Task<QuestionDto> addQuestion(QuestionDto question)
{
return QuestionManager.addQuestion(question);
}
public Task<QuestionDto?> removeQuestion(QuestionDto question)
{
return QuestionManager.removeQuestion(question);
}
public Task<QuestionDto?> removeQuestion(int id)
{
return QuestionManager.removeQuestion(id);
}
public Task<(int nbPages, IEnumerable<QuestionDto>? questions)> getQuestions(int nb, int count, QuestionOrderCriteria orderCriteria = QuestionOrderCriteria.ById)
{
return QuestionManager.getQuestions(nb, count, orderCriteria);
}
public Task<QuestionDto?> getQuestion(int id)
{
return QuestionManager.getQuestion(id);
}
public Task<QuestionDto?> updateQuestion(int id, QuestionDto question)
{
return QuestionManager.updateQuestion(id, question);
}
public Task<QuestionDto?> updateQuestionNbFalls(int id)
{
return QuestionManager.updateQuestionNbFalls(id);
}
public Task<IEnumerable<QuestionDto>> addQuestions(IEnumerable<QuestionDto> questions)
{
return QuestionManager.addQuestions(questions);
}
public Task<(int nbPages, IEnumerable<QuestionDto>? questions)?> getQuestionsByChapterAndDifficulty(int idChapter, int difficulty, int nb, int count, QuestionOrderCriteria orderCriteria = QuestionOrderCriteria.ById)
{
return QuestionManager.getQuestionsByChapterAndDifficulty(idChapter, difficulty, nb, count, orderCriteria);
}
}
}
Loading…
Cancel
Save