public bool GenerateAndSaveData() { List <Feed> feeds = _feedBuilder.Build(); if (feeds.IsNullOrEmpty()) { return(false); } var numberOfGeneratedFeeds = feeds.Count; foreach (var feed in feeds) { var feedData = new FeedData { CreatedUtc = feed.Updated, Link = feed.Link }; using (var ms = new MemoryStream()) { var serializer = new XmlSerializer(typeof(Feed), Ns); serializer.Serialize(ms, feed); feedData.FeedBytes = ms.ToArray(); } _feedRepository.Save(feedData); } // we only need to keep one version of each feed - remove older ones to avoid filling up the database _feedRepository.RemoveOldVersions(numberOfGeneratedFeeds); return(true); }
public bool GenerateAndSaveData() { var feed = _feedBuilder.Build(); if (feed == null) { return(false); } var feedData = new FeedData { Created = feed.Updated }; using (var ms = new MemoryStream()) { var serializer = new XmlSerializer(typeof(Feed), Ns); serializer.Serialize(ms, feed); feedData.FeedBytes = ms.ToArray(); } _feedRepository.Save(feedData); // we only need to keep one version - remove older ones to avoid filling up the database _feedRepository.RemoveOldVersion(); return(true); }