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