private (string Title, List <Article> Articles) SubscribeFeed(string feed, string appId) { var result = this.fetcher.Fetch(feed); if (result == default) { return(result); } using (var connection = this.helper.GetDbConnection()) { #region 插入 feed var feedDao = new FeedDao(connection); var feedId = feed.Md5(); var feedEntity = feedDao.GetFeed(feedId); if (feedEntity == null) { feedEntity = new Rss.Common.Entities.Feed { Id = feedId, Url = feed, Title = result.Title }; feedDao.InsertFeed(feedEntity); } #endregion #region 订阅 var subscriptionDao = new SubscriptionDao(connection); var subscription = subscriptionDao.GetSubscription(appId, feedId); if (subscription == null) { subscription = new Subscription { AppId = appId, FeedId = feedId }; subscriptionDao.InsertSubscription(subscription); } #endregion } return(result); }
public FeedController(FeedDao feedDao) { _feedDao = feedDao; }