You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
605 lines
26 KiB
605 lines
26 KiB
using DataManagers;
|
|
using DbConnectionLibrairie;
|
|
using DTOs;
|
|
using EntityManagers;
|
|
using ManagerInterfaces;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
using OrderCriterias;
|
|
using ServiceManagers;
|
|
using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
|
|
|
|
namespace WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// a controller just to separate route definition with route "documentation"
|
|
/// </summary>
|
|
[ApiVersion("1.0")]
|
|
[Route("api/v{version:apiversion}")]
|
|
[ApiController]
|
|
public class FrontController
|
|
{
|
|
|
|
private Unit unity;
|
|
|
|
// all secondary controllers
|
|
private AdministratorController administratorController;
|
|
private ChapterController chapterController;
|
|
private LobbyController lobbyController;
|
|
private PlayerController playerController;
|
|
private QuestionController questionController;
|
|
|
|
public FrontController(
|
|
AdministratorServiceManager administratorServiceManager,
|
|
AnswerServiceManager answerServiceManager,
|
|
ChapterServiceManager chapterServiceManager,
|
|
LobbyServiceManager lobbyServiceManager,
|
|
PlayerServiceManager playerServiceManager,
|
|
QuestionServiceManager questionServiceManager
|
|
){
|
|
this.unity = new Unit(
|
|
administratorServiceManager,
|
|
answerServiceManager,
|
|
chapterServiceManager,
|
|
lobbyServiceManager,
|
|
playerServiceManager,
|
|
questionServiceManager
|
|
);
|
|
administratorController = new AdministratorController(unity);
|
|
chapterController = new ChapterController(unity);
|
|
lobbyController = new LobbyController(unity);
|
|
playerController = new PlayerController(unity);
|
|
questionController = new QuestionController(unity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// add an administrator
|
|
/// </summary>
|
|
/// <param name="administrator">the administrator to add</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the administrator is added
|
|
/// 202 if the administrator is added
|
|
/// 208 if the administrator 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
|
|
/// administrator added when status code = 202
|
|
/// administrator 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/administrator/")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
|
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> PostAdministrator([FromBody] AdministratorDto administrator)
|
|
{
|
|
var tmp = await administratorController.PostAdministrator(administrator);
|
|
return tmp;
|
|
}
|
|
|
|
/// <summary>
|
|
/// get a part of all administrators
|
|
/// </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 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>
|
|
[HttpGet("administrators")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
public async Task<IActionResult> GetSomeAdministrators([FromQuery] int page, int count = 10,
|
|
AdministratorOrderCriteria orderCriteria = AdministratorOrderCriteria.ById)
|
|
=> await administratorController.GetSomeAdministrators(page, count, orderCriteria);
|
|
|
|
/// <summary>
|
|
/// delete an administrator
|
|
/// </summary>
|
|
/// <param name="id">the id of the administrator to delete</param>
|
|
/// <returns>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the administrator is removed
|
|
/// 204 if the administrator 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/administrator")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> DeleteAdministrator([FromQuery] int id)
|
|
=> await administratorController.DeleteAdministrator(id);
|
|
|
|
/// <summary>
|
|
/// update an administrator
|
|
/// </summary>
|
|
/// <param name="id">id of the administrator to update</param>
|
|
/// <param name="administrator">an administrator who contains all properties to change</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the administrator is modified
|
|
/// 204 if we wanted to modify an administrator who don't exist
|
|
/// 208 if the new username of the administrator is already used
|
|
/// 500 if there was an internal error that doesn't allow to continue
|
|
///
|
|
/// return content :
|
|
/// the administrator modified when status code = 200
|
|
/// nothing when status code = 204
|
|
/// the administrator that already have the username when status code = 208
|
|
/// nothing when status code = 500
|
|
/// </returns>
|
|
[HttpPut("update/administrator")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> PutAdministrator([FromQuery] int id, [FromBody] AdministratorDto administrator)
|
|
=> 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([FromQuery] string name)
|
|
=> await chapterController.GetChapter(name);
|
|
|
|
/// <summary>
|
|
/// add a lobby
|
|
/// </summary>
|
|
/// <param name="lobby">the lobby to add</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the lobby is added
|
|
/// 202 if the lobby is added
|
|
/// 208 if the lobby 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
|
|
/// lobby added when status code = 202
|
|
/// lobby 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/lobby")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
|
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> PostLobby([FromBody] LobbyDto lobby)
|
|
=> await lobbyController.PostLobby(lobby);
|
|
|
|
/// <summary>
|
|
/// get a part of all lobbies
|
|
/// </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 lobbies 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("lobbies")]
|
|
public async Task<IActionResult> GetSomeLobbies([FromQuery] int page, int count = 10, LobbyOrderCriteria orderCriteria = LobbyOrderCriteria.ById)
|
|
=> await lobbyController.GetSomeLobbies(page, count, orderCriteria);
|
|
|
|
/// <summary>
|
|
/// delete a lobby
|
|
/// </summary>
|
|
/// <param name="id">the id of the lobby to delete</param>
|
|
/// <returns>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the lobby is removed
|
|
/// 204 if the lobby 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/lobby")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> DeleteLobby([FromQuery] int id)
|
|
=> await lobbyController.DeleteLobby(id);
|
|
|
|
/// <summary>
|
|
/// get a lobby
|
|
/// </summary>
|
|
/// <param name="id">the id of the lobby</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 when we got a lobby
|
|
/// 204 when we got null
|
|
///
|
|
/// return content :
|
|
/// the lobby that correspond to the id when status code = 200
|
|
/// nothing when status code 204
|
|
/// </returns>
|
|
[HttpGet("lobbies/name")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
public async Task<IActionResult> GetLobby(int id)
|
|
=> await lobbyController.GetLobby(id);
|
|
|
|
/// <summary>
|
|
/// add a player
|
|
/// </summary>
|
|
/// <param name="player">the player to add</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the player is added
|
|
/// 202 if the player is added
|
|
/// 208 if the player 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
|
|
/// player added when status code = 202
|
|
/// player 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/player")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
|
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> PostPlayer([FromBody] PlayerDto player)
|
|
=> await playerController.PostPlayer(player);
|
|
|
|
/// <summary>
|
|
/// get a part of all players
|
|
/// </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 players 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/players")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> GetSomePlayers([FromQuery] int page, int count = 10, PlayerOrderCriteria orderCriteria = PlayerOrderCriteria.ById)
|
|
=> await playerController.GetSomePlayers(page, count, orderCriteria);
|
|
|
|
/// <summary>
|
|
/// delete a player
|
|
/// </summary>
|
|
/// <param name="id">the id of the player to delete</param>
|
|
/// <returns>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the player is removed
|
|
/// 204 if the player 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/player")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> DeletePlayer(int id)
|
|
=> await playerController.DeletePlayer(id);
|
|
|
|
/// <summary>
|
|
/// get a player
|
|
/// </summary>
|
|
/// <param name="id">the id of the player</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 when we got a player
|
|
/// 204 when we got null
|
|
///
|
|
/// return content :
|
|
/// the player that correspond to the id when status code = 200
|
|
/// nothing when status code = 204
|
|
/// </returns>
|
|
[HttpGet("player")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
public async Task<IActionResult> GetPlayer(int id)
|
|
=> await playerController.GetPlayer(id);
|
|
|
|
/// <summary>
|
|
/// update a player
|
|
/// </summary>
|
|
/// <param name="id">the id of the player</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 when we got a player
|
|
/// 204 when we got null
|
|
/// 208 when the nickname is already used
|
|
/// return content :
|
|
/// the player that correspond to the id when status code = 200
|
|
/// nothing when status code = 204
|
|
/// the player which have this nickname when status code = 208
|
|
/// </returns>
|
|
[HttpPut("update/player")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
|
|
public async Task<IActionResult> PutPlayer([FromQuery] int id, [FromBody] PlayerDto player)
|
|
=> await playerController.PutPlayer(id, player);
|
|
|
|
/// <summary>
|
|
/// add a question
|
|
/// </summary>
|
|
/// <param name="question">the question to add</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the question is added
|
|
/// 202 if the question is added
|
|
/// 208 if the question 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
|
|
/// question added when status code = 202
|
|
/// question 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/question")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
|
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> PostQuestion([FromBody] QuestionDto question)
|
|
=> await questionController.PostQuestion(question);
|
|
|
|
/// <summary>
|
|
/// get a part of all questions
|
|
/// </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 questions 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("questions/all")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
public async Task<IActionResult> GetSomeQuestions([FromQuery] int page, int count = 10, QuestionOrderCriteria orderCriteria = QuestionOrderCriteria.ById)
|
|
=> await questionController.GetSomeQuestions(page, count, orderCriteria);
|
|
|
|
/// <summary>
|
|
/// delete a question
|
|
/// </summary>
|
|
/// <param name="id">the id of the question to delete</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 if the question is removed
|
|
/// 204 if the question 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/question")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> DeleteQuestion([FromQuery] int id)
|
|
=> await questionController.DeleteQuestion(id);
|
|
|
|
/// <summary>
|
|
/// get a question
|
|
/// </summary>
|
|
/// <param name="id">the id of the question</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 when we got a question
|
|
/// 204 when we got null
|
|
///
|
|
/// return content :
|
|
/// the question that correspond to the id when status code = 200
|
|
/// nothing when status code = 204
|
|
/// </returns>
|
|
[HttpGet("question")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
public async Task<IActionResult> GetQuestion([FromQuery] int id)
|
|
=> await questionController.GetQuestion(id);
|
|
|
|
/// <summary>
|
|
/// update a question
|
|
/// </summary>
|
|
/// <param name="id">the id of the question</param>
|
|
/// <returns>
|
|
/// status code :
|
|
/// 200 when we got a question
|
|
/// 204 when we got null
|
|
/// 208 when the nickname is already used
|
|
/// return content :
|
|
/// the question that correspond to the id when status code = 200
|
|
/// nothing when status code = 204
|
|
/// the question which have this nickname when status code = 208
|
|
/// </returns>
|
|
[HttpPut]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status208AlreadyReported)]
|
|
public async Task<IActionResult> PutQuestion(int id, QuestionDto question)
|
|
=> await questionController.PutQuestion(id, question);
|
|
|
|
}
|
|
}
|