@ -40,12 +40,12 @@ namespace API.Controllers
[HttpGet("inquiry/{id:int}")]
[ProducesResponseType(typeof(InquiryDTO), 200)]
[ProducesResponseType(typeof(string), 404)]
public IActionResult GetInquiryById ( int id )
public async Task < IActionResult > GetInquiryById ( int id )
{
try
{
_logger . LogInformation ( "[INFORMATION] L'enquête avec l'id {id} a été trouvé." , id ) ;
return Ok ( _dataService . inquiryService . GetI nquiryById (id ) ) ;
return Ok ( await _dataService . inquiryService . GetI tems( 1 , 1 , null , I nquiryOrderCriteria. ById.ToString () . Substring ( 2 ) , id ) ) ;
}
catch ( ArgumentException )
{
@ -57,12 +57,12 @@ namespace API.Controllers
[HttpGet("inquiry/{title:alpha}")]
[ProducesResponseType(typeof(InquiryDTO), 200)]
[ProducesResponseType(typeof(string), 404)]
public IActionResult GetInquiryByTitle ( string title )
public async Task < IActionResult > GetInquiryByTitle ( string title )
{
try
{
_logger . LogInformation ( "[INFORMATION] L'enquête avec le titre {title} a été trouvé." , title ) ;
return Ok ( _dataService . inquiryService . GetI nquiryByTitle (title ) ) ;
return Ok ( await _dataService . inquiryService . GetI tems( 1 , 1 , null , I nquiryOrderCriteria. ByTitle.ToString () . Substring ( 2 ) , title ) ) ;
}
catch ( ArgumentException )
{
@ -93,21 +93,21 @@ namespace API.Controllers
[HttpPost]
[ProducesResponseType(typeof(InquiryDTO), 201)]
[ProducesResponseType(typeof(string), 400)]
public IActionResult CreateInquiry ( [ FromBody ] InquiryDTO dto )
public async Task < IActionResult > CreateInquiry ( [ FromBody ] InquiryDTO dto )
{
if ( dto . Title = = null | | dto . Description = = null )
{
return BadRequest ( ) ;
}
_logger . LogInformation ( "[INFORMATION] Une enquête a été créé : title - {title}, description - {description}, isUser - {isUser}" , dto . Title , dto . Description , dto . IsUser ) ;
return Created ( nameof ( GetInquiries ) , _dataService . inquiryService . CreateInquiry( dto . Title , dto . Description , dto . IsUser ) ) ;
return Created ( nameof ( GetInquiries ) , await _dataService . inquiryService . AddItem( dto ) ) ;
}
[HttpPut("inquiry/{id}")]
[ProducesResponseType(typeof(InquiryDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
public IActionResult UpdateInquiry ( int id , [ FromBody ] InquiryDTO inquiryDTO )
public async Task < IActionResult > UpdateInquiry ( int id , [ FromBody ] InquiryDTO inquiryDTO )
{
if ( id ! = inquiryDTO . Id )
{
@ -122,7 +122,7 @@ namespace API.Controllers
if ( inquiryDTO ! = null )
{
_logger . LogInformation ( "[INFORMATION] La mise à jour de l'enquête avec l'id {id} a été effectuée" , id ) ;
return Ok ( _dataService . inquiryService . UpdateI nquiry( id , inquiryDTO ) ) ;
return Ok ( await _dataService . inquiryService . UpdateI tem< I nquiryDTO> ( id , inquiryDTO ) ) ;
}
_logger . LogError ( "[ERREUR] Aucune enquête trouvée avec l'id {id}." , id ) ;
return NotFound ( ) ;