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