Exemplo n.º 1
0
        /// <summary>
        /// <see cref="IDataService.GetPodcast(int)"/>
        /// </summary>
        public Podcast GetPodcast(int podcastID)
        {
            Podcast podcast = _podcasts?.FirstOrDefault(i => i.PodcastID == podcastID);

            if (podcast != null)
            {
                return(podcast);
            }
            else
            {
                return(this.GetLastPodcastsFromDatabase(podcastID)?.FirstOrDefault());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialiazes a new instance of DesignDataService
        /// </summary>
        public DesignDataService()
        {
            for (int i = 1; i < 50; i++)
            {
                Podcast podcast = new Podcast(this.Configuration);
                podcast.PodcastID       = i;
                podcast.PodcastKey      = $"P{i}";
                podcast.PublicationDate = new DateTime(2015, 7, 7, 21, 0, 0).AddDays(i);
                podcast.Summary         = new PodcastSummary(podcast)
                {
                    Title   = $"Nouvelles fonctionnalités du C# 6.0 (n°{i})",
                    Authors = new PodcastAuthor[]
                    {
                        new PodcastAuthor(podcast)
                        {
                            Name = "Denis Voituron", Url = "https://twitter.com/denisvoituron"
                        },
                        new PodcastAuthor(podcast)
                        {
                            Name = "Christophe Peugnet", Url = "https://twitter.com/tossnet1"
                        },
                        new PodcastAuthor(podcast)
                        {
                            Name = "Laurent Bugnion", Url = "https://twitter.com/tossnet1"
                        }
                    },
                    Description = $"{i} - Le 20 juillet prochain, Microsoft lancera la nouvelle version de Visual Studio. Elle intègre nativement les nouvelles fonctionnalités du C# 6.0 : Dans ce premier podcast, je présente ces nouvelles syntaxes et nouvelles commandes du C# 6.0.",
                };
                podcast.Notes = "<h3>Podcast Notes</h3>Voici quelques liens sur ASP.NET MVC et Arnaud.<ul><li><a href=\"https://leanpub.com/aspnetmvc\" target=\"_blank\">Learn ASP.NET MVC - Livre d'Arnaud sur Leanpub.com</a></li></ul>";
                podcast.Audio = new PodcastAudio(podcast)
                {
                    RemoteUrl = "http://podcastdevapps.blob.core.windows.net/mp3/Podcast-01-NewFeaturesCSharp6.mp3",
                    Size      = 15031484,
                    Duration  = new TimeSpan(0, 15, 39),
                };
                podcast.Video = new PodcastVideo(podcast)
                {
                    RemoteUrl  = "http://podcastdevapps.blob.core.windows.net/mp4/Podcast-01-NewFeaturesCSharp6.mp4",
                    Size       = 42212019,
                    Duration   = new TimeSpan(0, 15, 39),
                    YoutubeKey = "yAieIX4-V4s"
                };

                _allPodcasts.Add(podcast);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// <see cref="IDataService.GetPodcastID(string)"/>
        /// </summary>
        /// <param name="shortUrl"></param>
        /// <returns></returns>
        public int?GetPodcastID(string shortUrl)
        {
            Podcast podcast = _podcasts?.FirstOrDefault(i => i.PodcastKey == shortUrl);

            if (podcast != null)
            {
                return(podcast.PodcastID);
            }
            else
            {
                using (SqlDatabaseCommand cmd = this.GetDatabaseCommand())
                {
                    cmd.CommandText.AppendLine(" SELECT PodcastID FROM Podcast WHERE PodcastKey = @Key ");
                    cmd.Parameters.AddWithValue("@Key", shortUrl);
                    return(cmd.ExecuteScalar <int?>());
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// <see cref="IDataService.GetSocialInformation(int)"/>
        /// </summary>
        /// <param name="podcastID"></param>
        /// <returns></returns>
        public SocialInformation GetSocialInformation(int podcastID)
        {
            SocialInformation data = new SocialInformation();

            data.Name               = "DevApps Podcasts";
            data.Authors            = "Denis Voituron / Christophe Peugnet";
            data.Language           = "fr-fr";
            data.GoogleAnalyticsKey = "UA-65328357-1";
            data.TwitterUrl         = "https://twitter.com/DevAppsPodcast";
            data.TwitterAccount     = "@DevAppsPodcast";
            data.CopyrightName      = "Denis Voituron";
            data.CopyrightUrl       = "http://www.dvoituron.be";
            data.CopyrightEmail     = "*****@*****.**";
            data.CategoriesKeywords = "Programming;Talk;Français;Podcast;Microsoft;Technology=Software How-To;Technology=Gadgets";
            data.ImageUrl           = "http://devapps.be/images/logo1400.png";
            data.Creator            = "@DevAppsPodcast";
            data.FeedAudioUrl       = "http://devapps.be/feed";
            data.FeedVideoUrl       = "http://devapps.be/video";
            data.FeedTitle          = "DevApps Podcasts, par Denis Voituron et Christophe Peugnet";

            Podcast podcast = this.GetPodcast(podcastID);

            // Header for Home Page
            if (podcast == null)
            {
                data.Title       = "DevApps Podcasts";
                data.Description = "DevApps - Actualité, Développement et Architecture en technologies .NET. Présenté par Denis Voituron et Christophe Peugnet, ce podcast ce veut technique et convivial.";
                data.Url         = "http://devapps.be";
            }

            // Header for podcast
            else
            {
                data.Title       = podcast.Summary.Title;
                data.Description = podcast.Summary.Description;
                data.Url         = $"http://devapps.be/podcast/{podcast.PodcastID}";
            }

            return(data);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="podcastID"></param>
        /// <returns></returns>
        public SocialInformation GetSocialInformation(int podcastID)
        {
            this.LoadConfigurationAndHeaders();

            // Global social information
            SocialInformation socialInformation = new SocialInformation()
            {
                Name               = _siteHeader.Name,
                Authors            = _siteHeader.Authors,
                Language           = _siteHeader.Language,
                GoogleAnalyticsKey = _siteHeader.GoogleAnalyticsKey,
                TwitterUrl         = _siteHeader.TwitterUrl,
                TwitterAccount     = _siteHeader.TwitterAccount,
                CopyrightName      = _siteHeader.CopyrightName,
                CopyrightUrl       = _siteHeader.CopyrightUrl,
                CopyrightEmail     = _siteHeader.CopyrightEmail,
                CategoriesKeywords = _siteHeader.CategoriesKeywords,
                ImageUrl           = _siteHeader.ImageUrl,
                Creator            = _siteHeader.Creator,
                FeedAudioUrl       = _siteHeader.FeedAudioUrl,
                FeedVideoUrl       = _siteHeader.FeedVideoUrl,
                FeedTitle          = _siteHeader.FeedTitle
            };

            // Custom social information
            Podcast podcast = this.GetPodcast(podcastID);

            if (podcast != null)
            {
                socialInformation.Title       = podcast.Summary.Title;
                socialInformation.Description = podcast.Summary.Description;
                socialInformation.Url         = podcast.PodcastUri.ToString();
            }

            return(socialInformation);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns only the specified podcast
        /// </summary>
        /// <param name="podcastID"></param>
        /// <returns></returns>
        private IEnumerable <Podcast> GetLastPodcastsFromDatabase(int podcastID)
        {
            int maxRows = Configuration.MaximumOfPodcastsOnHomePage;

            using (SqlDatabaseCommand cmd = this.GetDatabaseCommand())
            {
                string onlyOnePodcast = podcastID > 0 ? $" AND PodcastID = {podcastID}" : String.Empty;

                // Search all authors for last podcasts
                cmd.Clear();
                cmd.CommandText.AppendLine($" SELECT PodcastID, Name, Url ");
                cmd.CommandText.AppendLine($"   FROM PodcastAuthor ");
                cmd.CommandText.AppendLine($"  INNER JOIN PodcastAuthorLink ON PodcastAuthorLink.PodcastAuthorID = PodcastAuthor.PodcastAuthorID ");
                cmd.CommandText.AppendLine($"  WHERE PodcastAuthorLink.PodcastID IN (SELECT TOP {maxRows} PodcastID FROM Podcast ORDER BY PublicationDate DESC) ");
                cmd.CommandText.AppendLine(onlyOnePodcast);

                var authors = cmd.ExecuteTable((row) =>
                {
                    return(new
                    {
                        PodcastID = row.Field <int>("PodcastID"),
                        Name = row.Field <string>("Name"),
                        Url = row.Field <string>("Url"),
                    });
                });

                // Select last podcasts
                cmd.Clear();
                cmd.CommandText.AppendLine($" SELECT TOP {maxRows} * ");
                cmd.CommandText.AppendLine($"   FROM Podcast ");
                cmd.CommandText.AppendLine($"  WHERE 1=1 " + onlyOnePodcast);
                cmd.CommandText.AppendLine($"  ORDER BY PublicationDate DESC ");

                return(cmd.ExecuteTable((row) =>
                {
                    int id = row.Field <int>("PodcastID");

                    Podcast podcast = new Podcast(this.Configuration);
                    podcast.PodcastID = id;
                    podcast.PodcastKey = row.Field <string>("PodcastKey");
                    podcast.PublicationDate = row.Field <DateTime>("PublicationDate");
                    podcast.Summary = new PodcastSummary(podcast)
                    {
                        Title = row.Field <string>("SummaryTitle"),
                        Description = row.Field <string>("SummaryDescription"),
                        Authors = authors.Where(i => i.PodcastID == id)
                                  .OrderBy(i => i.Name)
                                  .Select(i => new PodcastAuthor(podcast)
                        {
                            Name = i.Name,
                            Email = String.Empty,
                            Url = i.Url
                        })
                                  .ToArray()
                    };
                    podcast.Notes = row.Field <string>("Notes");
                    podcast.Audio = new PodcastAudio(podcast)
                    {
                        RemoteUrl = row.Field <string>("AudioUrl"),
                        Size = (uint)row.Field <int>("AudioSize"),
                        Duration = row.Field <TimeSpan>("AudioDuration"),
                    };
                    podcast.Video = new PodcastVideo(podcast)
                    {
                        RemoteUrl = row.Field <string>("VideoUrl"),
                        Size = (uint)row.Field <int>("VideoSize"),
                        Duration = row.Field <TimeSpan>("VideoDuration"),
                        YoutubeKey = row.Field <string>("VideoYoutubeKey"),
                    };

                    return podcast;
                }));
            }
        }
Exemplo n.º 7
0
 public PodcastVideo(Podcast podcast) : base(podcast)
 {
 }
Exemplo n.º 8
0
 public PodcastAudio(Podcast podcast) : base(podcast)
 {
 }
Exemplo n.º 9
0
 public PodcastAuthor(Podcast podcast)
 {
 }
Exemplo n.º 10
0
 public PodcastSummary(Podcast podcast)
 {
 }
Exemplo n.º 11
0
 public PodcastMedia(Podcast podcast)
 {
     _podcast = podcast;
 }