Adding 404 to every related query

This commit is contained in:
Zoe Roux 2020-09-24 20:32:55 +02:00
parent 6950b6750a
commit faa908de7b
7 changed files with 56 additions and 128 deletions

View File

@ -45,11 +45,9 @@ namespace Kyoo.Api
new Sort<Show>(sortBy), new Sort<Show>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetCollection(id) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -77,11 +75,9 @@ namespace Kyoo.Api
new Sort<Show>(sortBy), new Sort<Show>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetCollection(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -109,11 +105,9 @@ namespace Kyoo.Api
new Sort<Library>(sortBy), new Sort<Library>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetCollection(id) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -141,11 +135,9 @@ namespace Kyoo.Api
new Sort<Library>(sortBy), new Sort<Library>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetCollection(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {

View File

@ -87,11 +87,9 @@ namespace Kyoo.Api
new Sort<Track>(sortBy), new Sort<Track>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetEpisode(episodeID) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -123,11 +121,9 @@ namespace Kyoo.Api
new Sort<Track>(sortBy), new Sort<Track>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetEpisode(showID, seasonNumber, episodeNumber) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -158,11 +154,9 @@ namespace Kyoo.Api
new Sort<Track>(sortBy), new Sort<Track>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {

View File

@ -49,10 +49,6 @@ namespace Kyoo.Api
return NotFound(); return NotFound();
return Page(resources, limit); return Page(resources, limit);
} }
catch (ItemNotFound)
{
return NotFound();
}
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
return BadRequest(new {Error = ex.Message}); return BadRequest(new {Error = ex.Message});
@ -83,10 +79,6 @@ namespace Kyoo.Api
return NotFound(); return NotFound();
return Page(resources, limit); return Page(resources, limit);
} }
catch (ItemNotFound)
{
return NotFound();
}
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
return BadRequest(new {Error = ex.Message}); return BadRequest(new {Error = ex.Message});

View File

@ -56,11 +56,9 @@ namespace Kyoo.Api
new Sort<Show>(sortBy), new Sort<Show>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetLibrary(id) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -88,11 +86,9 @@ namespace Kyoo.Api
new Sort<Show>(sortBy), new Sort<Show>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetLibrary(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -120,11 +116,9 @@ namespace Kyoo.Api
new Sort<Collection>(sortBy), new Sort<Collection>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetLibrary(id) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -152,11 +146,9 @@ namespace Kyoo.Api
new Sort<Collection>(sortBy), new Sort<Collection>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetLibrary(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -184,11 +176,9 @@ namespace Kyoo.Api
new Sort<LibraryItem>(sortBy), new Sort<LibraryItem>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetLibrary(id) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -216,11 +206,9 @@ namespace Kyoo.Api
new Sort<LibraryItem>(sortBy), new Sort<LibraryItem>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetLibrary(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {

View File

@ -45,11 +45,9 @@ namespace Kyoo.Api
new Sort<Episode>(sortBy), new Sort<Episode>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetSeason(seasonID) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -79,11 +77,9 @@ namespace Kyoo.Api
new Sort<Episode>(sortBy), new Sort<Episode>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetSeason(showSlug, seasonNumber) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -112,11 +108,9 @@ namespace Kyoo.Api
new Sort<Episode>(sortBy), new Sort<Episode>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetSeason(showID, seasonNumber) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {

View File

@ -45,11 +45,9 @@ namespace Kyoo.Api
new Sort<Season>(sortBy), new Sort<Season>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(showID) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -77,11 +75,9 @@ namespace Kyoo.Api
new Sort<Season>(sortBy), new Sort<Season>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -109,11 +105,9 @@ namespace Kyoo.Api
new Sort<Episode>(sortBy), new Sort<Episode>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(showID) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -141,11 +135,9 @@ namespace Kyoo.Api
new Sort<Episode>(sortBy), new Sort<Episode>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -172,11 +164,9 @@ namespace Kyoo.Api
new Sort<PeopleRole>(sortBy), new Sort<PeopleRole>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(showID) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -203,11 +193,9 @@ namespace Kyoo.Api
new Sort<PeopleRole>(sortBy), new Sort<PeopleRole>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -235,11 +223,9 @@ namespace Kyoo.Api
new Sort<Genre>(sortBy), new Sort<Genre>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(showID) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -267,11 +253,9 @@ namespace Kyoo.Api
new Sort<Genre>(sortBy), new Sort<Genre>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -327,11 +311,9 @@ namespace Kyoo.Api
new Sort<Library>(sortBy), new Sort<Library>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(showID) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -359,11 +341,9 @@ namespace Kyoo.Api
new Sort<Library>(sortBy), new Sort<Library>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -391,11 +371,9 @@ namespace Kyoo.Api
new Sort<Collection>(sortBy), new Sort<Collection>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(showID) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@ -423,11 +401,9 @@ namespace Kyoo.Api
new Sort<Collection>(sortBy), new Sort<Collection>(sortBy),
new Pagination(limit, afterID)); new Pagination(limit, afterID));
return Page(resources, limit); if (!resources.Any() && await _libraryManager.GetShow(slug) == null)
}
catch (ItemNotFound)
{
return NotFound(); return NotFound();
return Page(resources, limit);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {

View File

@ -49,10 +49,6 @@ namespace Kyoo.Api
return NotFound(); return NotFound();
return Page(resources, limit); return Page(resources, limit);
} }
catch (ItemNotFound)
{
return NotFound();
}
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
return BadRequest(new {Error = ex.Message}); return BadRequest(new {Error = ex.Message});
@ -83,10 +79,6 @@ namespace Kyoo.Api
return NotFound(); return NotFound();
return Page(resources, limit); return Page(resources, limit);
} }
catch (ItemNotFound)
{
return NotFound();
}
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
return BadRequest(new {Error = ex.Message}); return BadRequest(new {Error = ex.Message});