Esempio n. 1
0
        public override async Task InitializeAsync()
        {
            SetL10NResources();
            IsBusy = true;
            _dialogService.ShowLoading();
            var podcastDetails = new List <PodcastModel>();

            _podcastsGUID    = new List <Podcast>();
            Categories       = new List <string>();
            SelectedCategory = _allLabel;

            try
            {
                _podcastsGUID = await _podcastService.GetTopTenPodcastsAsync(RSSFeed.TopTenPodcasts);

                foreach (Podcast podcast in _podcastsGUID)
                {
                    string podGUID = RegexHelper.GetPodcastId(podcast.PodcastGUID);
                    Debug.WriteLine($"{podGUID} \n");

                    if (!podGUID.All(char.IsDigit))
                    {
                        continue;
                    }

                    var pcDetail = await _podcastService.GetPodcastDetailAsync(podGUID);

                    var podCast = ReflectionHelper.ConvertNullToEmpty(pcDetail[0]);

                    podcastDetails.Add(podCast);
                    Categories.Add(podCast.PrimaryGenre);
                }
                Categories.Add(_allLabel);
                Categories        = Categories.Distinct().ToList().OrderBy(x => x).ToList();
                PodcastDetail     = podcastDetails.OrderByDescending(x => x.ReleaseDate).ToList();
                _savedPodcastList = PodcastDetail;
            }
            catch (Exception ex)
            {
                Ui.Handle(ex as dynamic);
            }
            finally
            {
                IsBusy = false;
                _dialogService.HideLoading();
            }
        }