示例#1
0
        public void AddPodcastEpisodes(int podcastId)
        {
            var dto = _podcastRepository.GetPodcast(podcastId);

            var feed = _rssParser.ParseRssFeed(dto.FeedUrl);

            if (feed == null)
            {
                return;
            }

            var episodes = from item in feed.SyndicationFeed.Items
                           let episodeUrl = GetEpisodeUrl(item)
                                            let audioUrl = GetAudioUrl(item)
                                                           select new EpisodeDto
            {
                Title         = item.Title?.Text,
                Summary       = item.Summary?.Text,
                EpisodeUrl    = episodeUrl,
                AudioUrl      = audioUrl,
                DatePublished = item.PublishDate.DateTime,
                DateCreated   = DateTime.Now
            };

            dto.Episodes = episodes;

            _podcastRepository.AddEpisodesToPodcast(dto);
        }