|
|
|
@ -85,7 +85,7 @@ namespace WfApi.Controllers
|
|
|
|
|
var existingFavorite = await _favorite.GetFavorite(idUser, idQuote);
|
|
|
|
|
if (existingFavorite == null)
|
|
|
|
|
{
|
|
|
|
|
return NotFound(new { message = "Commentary not found." });
|
|
|
|
|
return NotFound(new { message = "Favorite not found." });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _favorite.RemoveFavorite(idUser, idQuote);
|
|
|
|
@ -97,24 +97,36 @@ namespace WfApi.Controllers
|
|
|
|
|
return StatusCode((int)HttpStatusCode.InternalServerError, new { message = "Internal server error." });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpDelete] // /api/v1/commentary?id=51
|
|
|
|
|
[HttpDelete("alluser")] // /api/v1/commentary?id=51
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<IActionResult> DeleteFavorite([FromQuery] int idUser, [FromQuery] int idQuote)
|
|
|
|
|
public async Task<IActionResult> DeleteAllFavoriteForUser([FromQuery] int idUser)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var existingFavorite = await _favorite.GetFavorite(idUser, idQuote);
|
|
|
|
|
if (existingFavorite == null)
|
|
|
|
|
{
|
|
|
|
|
return NotFound(new { message = "Commentary not found." });
|
|
|
|
|
}
|
|
|
|
|
await _favorite.RemoveAllFavoriteForUser(idUser);
|
|
|
|
|
|
|
|
|
|
await _favorite.RemoveFavorite(idUser, idQuote);
|
|
|
|
|
return Ok(new { message = $"Favorite from user {idUser} deleted successfully." });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return StatusCode((int)HttpStatusCode.InternalServerError, new { message = "Internal server error." });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpDelete("allquote")] // /api/v1/commentary?id=51
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<IActionResult> DeleteAllFavoriteForQuote([FromQuery] int idQuote)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return Ok(new { message = $"Favorite from user {idUser} and quote {idQuote} deleted successfully." });
|
|
|
|
|
await _favorite.RemoveAllFavoriteForQuote(idQuote);
|
|
|
|
|
|
|
|
|
|
return Ok(new { message = $"Favorite from quote {idQuote} deleted successfully." });
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|