public IDictionary <string, IEnumerable <FileInfo> > GetChannelDocumentsDictionary() { Dictionary <string, IEnumerable <FileInfo> > result = new Dictionary <string, IEnumerable <FileInfo> >(); IEnumerable <JObject> channels = GetChannelListItems(Settings.SharePointGroupId, Settings.ChannelListName); IEnumerable <JObject> teamsChannelDoclistItems = sharePointController.GetListItems(graphClientManager.GetGraphHttpClient(), Settings.SharePointGroupId, Settings.ChannelDocListName); foreach (JObject item in teamsChannelDoclistItems) { string channelid = item["fields"]?[Settings.ChannelDocChannelNameField]?.ToString(); if (channelid != null) { string channelName = channels.FirstOrDefault(x => x["fields"]?["id"]?.ToString() == channelid)["fields"]? [Settings.ChannelNameField]?.ToString(); if (!string.IsNullOrWhiteSpace(channelName)) { string fileName = item["fields"]?[Settings.ChannelDocFileNameField]?.ToString(); if (!string.IsNullOrWhiteSpace(fileName)) { string fileDownloadUrl = sharePointController.GetDocItemDownloadUrl(graphClientManager.GetGraphHttpClient(), Settings.SharePointGroupId, Settings.ChannelDocListName, item["id"].ToString()); string tempFileName = $"{TempFileFolder}/{fileName}"; DownLoadTemplateFile(tempFileName, fileDownloadUrl); if (result.ContainsKey(channelName)) { ((List <FileInfo>)result[channelName]).Add(new FileInfo(tempFileName)); } else { List <FileInfo> fileList = new List <FileInfo> { new FileInfo(tempFileName) }; result.Add(channelName, fileList); } } else { throw new AutoTeamsStructureException($"Document file name cannot be found in document template list for item {item["id"]}"); } } else { throw new AutoTeamsStructureException($"Channel name cannot be found in document template list for item {item["id"]}"); } } } return(result); }