Esempio n. 1
0
        private async void LoadData(string id)
        {
            Message = Core.StringMessage.LoadingPleaseWait;
            if (!App.Locator.Network.IsActive)
            {
                Message = Core.StringMessage.NoInternetConnection;
                return;
            }

            ClearSpotifyAlbumViewModelData();

            Tracks = new ObservableCollection <Base>();

            IsLoading = true;

            try
            {
                var o = await _service.GetDetailAlbumByMbid(id);

                int indexToAdd = -1;

                foreach (var simpleTrack in o?.Tracks)
                {
                    simpleTrack.ArtistName = o.ArtistName;
                    indexToAdd++;
                    Tracks.Add(Data.Model.WebSongConverter.CreateSong(simpleTrack as LastTrack));
                    if (indexToAdd == 2 || indexToAdd == 10 || indexToAdd == 22 || indexToAdd == 34 || indexToAdd == 49 ||
                        indexToAdd == 63 || indexToAdd == 78 || indexToAdd == 88 || indexToAdd == 99)
                    {
                        Tracks.Insert(indexToAdd, new ListAdvert());
                    }
                }


                Name  = o.Name;
                Album = o;
            }
            catch
            {
                Message = Core.StringMessage.SomethinWentWrong;
            }

            if (Album != null && (Tracks != null && Tracks.Count > 0))
            {
                Message = Core.StringMessage.NoMessge;
            }
            else
            {
                Message = Core.StringMessage.EmptyMessage;
            }
            IsLoading = false;
        }