mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-16 21:20:06 +01:00
fix: handle requests with a non-integer list for category_id
This commit is contained in:
@@ -54,10 +54,21 @@ public class QuotesController : ControllerBase
|
|||||||
var totalQuotes = await _db.Quotes.CountAsync();
|
var totalQuotes = await _db.Quotes.CountAsync();
|
||||||
const int PageSize = 10;
|
const int PageSize = 10;
|
||||||
|
|
||||||
List<int>? categories = category_id?
|
List<int>? categories;
|
||||||
.Split(",")
|
try
|
||||||
.Select(Int32.Parse)
|
{
|
||||||
.ToList();
|
categories = category_id?
|
||||||
|
.Split(",")
|
||||||
|
.Select(Int32.Parse)
|
||||||
|
.ToList();
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
// Try to catch badly formatted requests
|
||||||
|
return BadRequest(new ErrorDTO {
|
||||||
|
Status = "error",
|
||||||
|
Error_msg = "Category_id can be either an integer, or comma separated integers"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (page_no <= 0)
|
if (page_no <= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user