From 86712714f22ea63ddcb313420eea5f4943e9218a Mon Sep 17 00:00:00 2001 From: glax <--local> Date: Thu, 18 May 2023 19:12:17 +0200 Subject: [PATCH] Implemented CreateUpdateChaptersTask Implemented CreateUpdatePublicationsTask --- Tranga/TrangaTask.cs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Tranga/TrangaTask.cs b/Tranga/TrangaTask.cs index 0d259be..4aac005 100644 --- a/Tranga/TrangaTask.cs +++ b/Tranga/TrangaTask.cs @@ -35,15 +35,30 @@ public class TrangaTask } return new TrangaTask(TaskAction, reoccurrence); } - - public static TrangaTask CreateUpdateChaptersTask(Connector connector, Publication publication, TimeSpan reoccurrence) + public static TrangaTask CreateUpdateChaptersTask(ref Dictionary chapterCollection, Connector connector, Publication publication, string language, TimeSpan reoccurrence) { - throw new NotImplementedException(); + Dictionary pChapterCollection = chapterCollection; + + void TaskAction() + { + Chapter[] chapters = connector.GetChapters(publication, language); + if(pChapterCollection.TryAdd(publication, chapters)) + pChapterCollection[publication] = chapters; + } + return new TrangaTask(TaskAction, reoccurrence); } - public static TrangaTask CreateUpdatePublicationsTask(Connector connector, TimeSpan reoccurrence) + public static TrangaTask CreateUpdatePublicationsTask(ref Dictionary chapterCollection, Connector connector, TimeSpan reoccurrence) { - throw new NotImplementedException(); + Dictionary pChapterCollection = chapterCollection; + + void TaskAction() + { + Publication[] publications = connector.GetPublications(); + foreach (Publication publication in publications) + pChapterCollection.TryAdd(publication, Array.Empty()); + } + return new TrangaTask(TaskAction, reoccurrence); } } \ No newline at end of file