Ejemplo n.º 1
0
        private void DeleteCommandExecute()
        {
            var request = new HttpRequestGet();

            ValidateKey.GetValideKey();
            Carts cart = null;

            foreach (var item in _listCarts)
            {
                if (SelectedAlbum != null && (item.albums.Count > 0 && item.albums[0].id == SelectedAlbum.id))
                    cart = item;
                else if (SelectedMusic != null &&
                         (item.musics.Count > 0 && item.musics[0].id == SelectedMusic.id))
                    cart = item;
            }

            var resDel = request.DeleteFromCart(cart, Singleton.Singleton.Instance().SecureKey,
                Singleton.Singleton.Instance().CurrentUser);

            resDel.ContinueWith(delegate(Task<string> tmp)
            {
                var test = tmp.Result;
                if (test != null)
                {
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        var stringJson = JObject.Parse(test).SelectToken("code").ToString();
                        if (stringJson == "202")
                        {
                            new MessageDialog("Article supprime").ShowAsync();
                            Charge();
                        }
                        else
                            new MessageDialog("Delete Fail code: " + stringJson).ShowAsync();
                    });
                }
            });
        }