Website: On Download Chapters only show chapters that have not yet been downloaded

API: Added new variables to /Publications/GetChapters: onlyNew and onlyExisting. API will return only new, only existing or all chapters depending on variables.
#19
This commit is contained in:
2023-06-15 17:14:20 +02:00
parent b571bfa43d
commit 8b58e7dd13
3 changed files with 11 additions and 5 deletions

View File

@ -75,7 +75,7 @@ app.MapGet("/Publications/GetFromConnector", (string connectorName, string title
return taskManager.GetPublicationsFromConnector(connector, title);
});
app.MapGet("/Publications/GetChapters", (string connectorName, string internalId, string? language) =>
app.MapGet("/Publications/GetChapters", (string connectorName, string internalId, bool onlyNew, bool onlyExisting, string? language) =>
{
Connector? connector = taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName).Value;
if (connector is null)
@ -83,7 +83,13 @@ app.MapGet("/Publications/GetChapters", (string connectorName, string internalId
Publication? publication = taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId);
if (publication is null)
return Array.Empty<Chapter>();
return connector.GetChapters((Publication)publication, language??"en");
if(onlyNew)
return taskManager.GetNewChaptersList(connector, (Publication)publication, language??"en").ToArray();
else if (onlyExisting)
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)));