public List<PodcastGroup> GenerateGroups(List<Podcast> podcasts)
        {
            StatisticsProcessor sp = new StatisticsProcessor();

            List<PodcastGroup> podcastGroups = new List<PodcastGroup>();

            PodcastGroup generalGroup = new PodcastGroup("Geral");
            generalGroup.podcasts = podcasts;
            sp.ProcessStatistics(generalGroup);

            List<PodcastGroup> yearlyGroups = this.SplitYearly(podcasts);
            foreach(PodcastGroup pg in yearlyGroups)
            {
                sp.ProcessStatistics(pg);
            }

            podcastGroups.Add(generalGroup);
            podcastGroups.AddRange(yearlyGroups);

            return podcastGroups;
        }
        public void ProcessStatistics(PodcastGroup pg)
        {
            PodcastStatistics ps = new PodcastStatistics();
            ps.quantity = pg.podcasts.Count;
            ps.size = 0;
            TimeSpan totalDuration = new TimeSpan();
            TimeSpan averageDuration = new TimeSpan();

            foreach(Podcast podcast in pg.podcasts)
            {
                ps.size += podcast.size;
                totalDuration = totalDuration.Add(podcast.duration);
            }

            Double averageMiliseconds = totalDuration.TotalMilliseconds / pg.podcasts.Count;
            averageDuration = TimeSpan.FromMilliseconds(averageMiliseconds);

            ps.totalDuration = totalDuration;
            ps.averageDuration = averageDuration;

            pg.statistics = ps;
        }
        private List<PodcastGroup> SplitYearly(List<Podcast> podcasts)
        {
            List<PodcastGroup> yearlyGroups = new List<PodcastGroup>();
            Dictionary<int, List<Podcast>> years = new Dictionary<int, List<Podcast>>();

            foreach (Podcast podcast in podcasts)
            {
                int year = podcast.publicationDate.Year;
                if(!years.ContainsKey(year))
                {
                    years.Add(year, new List<Podcast>());
                }
                years[year].Add(podcast);
            }

            foreach (int year in years.Keys)
            {
                PodcastGroup pg = new PodcastGroup(year.ToString());
                pg.podcasts = years[year];
                yearlyGroups.Add(pg);
            }

            return yearlyGroups;
        }