public void CopyRssThatWerePublishedAfterLastReadTimeToUser(long currentUserId, List<RssChannelSubscriptionDTO> subscriptions) { var rssChannelsIds = subscriptions.Select(x => x.RssChannelId).ToList(); var rssEntries = this.database.RssEntries .Where(e => rssChannelsIds.Contains(e.RssChannelId)) .Include(e => e.RssEntryToRead) .Where(e => e.RssEntryToRead == null) .ToList(); var toread = new List<RssEntryToRead>(rssEntries.Count); rssEntries.ForEach(entry => { var rssEntryToRead = new RssEntryToRead( entry, subscriptions.Single(x => x.RssChannelId == entry.RssChannelId).Id); toread.Add(rssEntryToRead); }); this.database.RssEntriesToRead.AddRange(toread); this.database.SaveChanges(); }
private RssStatistics ToRssStatistics(RssEntryToRead model) { var projection = new RssStatistics { Id = model.RssEntry.Id, Name = model.RssEntry.Title, Preview = model.RssEntry.PreviewText, }; return projection; }