API: Fix nullable bug on Getchapters
This commit is contained in:
parent
5b2546fdbc
commit
dda4054d34
@ -75,8 +75,13 @@ app.MapGet("/Publications/GetFromConnector", (string connectorName, string title
|
||||
return taskManager.GetPublicationsFromConnector(connector, title);
|
||||
});
|
||||
|
||||
app.MapGet("/Publications/GetChapters", (string connectorName, string internalId, bool onlyNew, bool onlyExisting, string? language) =>
|
||||
{
|
||||
app.MapGet("/Publications/GetChapters",
|
||||
(string connectorName, string internalId, string? onlyNew, string? onlyExisting, string? language) =>
|
||||
{
|
||||
string[] yes = { "true", "yes", "1", "y" };
|
||||
bool newOnly = onlyNew is not null && yes.Contains(onlyNew);
|
||||
bool existingOnly = onlyExisting is not null && yes.Contains(onlyExisting);
|
||||
|
||||
Connector? connector = taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName).Value;
|
||||
if (connector is null)
|
||||
return Array.Empty<Chapter>();
|
||||
@ -84,9 +89,9 @@ app.MapGet("/Publications/GetChapters", (string connectorName, string internalId
|
||||
if (publication is null)
|
||||
return Array.Empty<Chapter>();
|
||||
|
||||
if(onlyNew)
|
||||
if(newOnly)
|
||||
return taskManager.GetNewChaptersList(connector, (Publication)publication, language??"en").ToArray();
|
||||
else if (onlyExisting)
|
||||
else if (existingOnly)
|
||||
return taskManager.GetExistingChaptersList(connector, (Publication)publication, language ?? "en").ToArray();
|
||||
else
|
||||
return connector.GetChapters((Publication)publication, language??"en");
|
||||
|
Loading…
Reference in New Issue
Block a user