public Task <Dictionary <string, PodcastFeed> > GetFeedsAsync() { if (hasAll) { return(Task.FromResult(_inMemory)); } else { FeedOptions queryOptions = new FeedOptions { MaxItemCount = -1 }; IQueryable <FeedDocument> feeds = _client.CreateDocumentQuery <FeedDocument>( UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), queryOptions); var allFeeds = feeds .ToList(); var dictionary = allFeeds.ToDictionary(fd => fd.Name, fd => { var feed = new PodcastFeed(fd.Url); feed.Refresh(); return(feed); }); _inMemory = dictionary; return(Task.FromResult(dictionary)); } }
public async Task AddFeedAsync(string name, PodcastFeed feed) { try { var feedDocument = new FeedDocument { Name = name, Url = feed.Url.ToString() }; _inMemory.Add(name, feed); feed.Refresh(); await _client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), feedDocument); } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }