@ -25,13 +25,16 @@ namespace WfApi.Controllers
//===================================== ROUTE GET =====================================
[HttpGet("{id}")] // Indiquer que l'id est dans l'URL
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetQuote ( int id )
{
try
{
var result = _quote . GetQuoteById ( id ) ;
var result = await _quote . GetQuoteById ( id ) ;
if ( result .IsCompletedSuccessfully )
if ( result != null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -48,13 +51,16 @@ namespace WfApi.Controllers
[HttpGet("all")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetAllQuote ( int index = 0 , int count = 10 )
{
try
{
var result = _quote . GetSomeQuote ( index , count ) ;
var result = await _quote . GetSomeQuote ( index , count ) ;
if ( result . IsCompletedSuccessfully )
if ( result ! = null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -69,13 +75,16 @@ namespace WfApi.Controllers
}
}
[HttpGet("allbylang")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetAllQuoteByLang ( TypeLangageDTO lang , int index = 0 , int count = 10 )
{
try
{
var result = _quote . GetAllQuoteLang ( index , count , ( int ) lang ) ;
var result = await _quote . GetAllQuoteLang ( index , count , ( int ) lang ) ;
if ( result . IsCompletedSuccessfully )
if ( result ! = null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -90,15 +99,18 @@ namespace WfApi.Controllers
}
}
[HttpGet("dailyquote")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetDailyQuote ( [ FromQuery ] int year , [ FromQuery ] int month , [ FromQuery ] int day , TypeLangageDTO lang )
{
try
{
DateOnly date = new DateOnly ( year , month , day ) ;
var result = _quote . GetDailyQuote ( date , ( int ) lang ) ;
var result = await _quote . GetDailyQuote ( date , ( int ) lang ) ;
if ( result . IsCompletedSuccessfully )
if ( result ! = null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -113,13 +125,16 @@ namespace WfApi.Controllers
}
}
[HttpGet("invalid")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetInvalidQuote ( TypeLangageDTO lang , int index = 0 , int count = 10 )
{
try
{
var result = _quote . GetInvalidQuote ( index , count , ( int ) lang ) ;
var result = await _quote . GetInvalidQuote ( index , count , ( int ) lang ) ;
if ( result . IsCompletedSuccessfully )
if ( result ! = null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -134,13 +149,16 @@ namespace WfApi.Controllers
}
}
[HttpGet("suggest")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetSuggestQuote ( TypeLangageDTO lang , int index = 0 , int count = 10 )
{
try
{
var result = _quote . GetSuggestions ( index , count , ( int ) lang ) ;
var result = await _quote . GetSuggestions ( index , count , ( int ) lang ) ;
if ( result . IsCompletedSuccessfully )
if ( result ! = null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -155,13 +173,16 @@ namespace WfApi.Controllers
}
}
[HttpGet("searchByCharacter")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetQuoteSearchByCharacter ( TypeLangageDTO lang , string character , int index = 0 , int count = 10 )
{
try
{
var result = _quote . SearchByCharacter ( character , index , count , ( int ) lang ) ;
var result = await _quote . SearchByCharacter ( character , index , count , ( int ) lang ) ;
if ( result . IsCompletedSuccessfully )
if ( result ! = null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -176,13 +197,16 @@ namespace WfApi.Controllers
}
}
[HttpGet("searchByCharac")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetQuoteSearchBySource ( TypeLangageDTO lang , string source , int index = 0 , int count = 10 )
{
try
{
var result = _quote . SearchBySource ( source , index , count , ( int ) lang ) ;
var result = await _quote . SearchBySource ( source , index , count , ( int ) lang ) ;
if ( result . IsCompletedSuccessfully )
if ( result ! = null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -197,13 +221,16 @@ namespace WfApi.Controllers
}
}
[HttpGet("searchByContent")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > GetQuoteSearchByContent ( TypeLangageDTO lang , string content , int index = 0 , int count = 10 )
{
try
{
var result = _quote . SearchByContent ( content , index , count , ( int ) lang ) ;
var result = await _quote . SearchByContent ( content , index , count , ( int ) lang ) ;
if ( result . IsCompletedSuccessfully )
if ( result ! = null )
{
return await Task . FromResult < IActionResult > ( Ok ( result ) ) ;
}
@ -221,6 +248,9 @@ namespace WfApi.Controllers
//===================================== ROUTE POST =====================================
[HttpPost]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > CreateQuote ( [ FromBody ] QuoteDTO newQuote )
{
try
@ -247,6 +277,9 @@ namespace WfApi.Controllers
}
//===================================== ROUTE PUT =====================================
[HttpPut()]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > UpdateQuote ( [ FromQuery ] int id , [ FromBody ] QuoteDTO updatedquote )
{
try
@ -266,6 +299,9 @@ namespace WfApi.Controllers
}
}
[HttpPut("valide")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > ValideQuote ( [ FromQuery ] int id )
{
try
@ -289,6 +325,9 @@ namespace WfApi.Controllers
//===================================== ROUTE DELETE =====================================
[HttpDelete("delete")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task < IActionResult > DeleteQuote ( [ FromQuery ] int idQuote )
{
try