Пример #1
0
        private async void Button_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var title     = Title.Text;
            var thumbnail = Url_Thumbnail.Text;
            var song      = Url_Song.Text;

            if (title == "")
            {
                Title_Message.Text = "Title is empty!";
            }
            else
            {
                Title_Message.Text = "";
            }
            if (thumbnail == "")
            {
                Url_Thumbnail_Mesage.Text = "Thumbnail is empty!";
            }
            else
            {
                Url_Thumbnail_Mesage.Text = "";
            }
            if (song == "")
            {
                Url_Song_Message.Text = "Song url is empty!";
            }
            if (Check_Url_Song(song))
            {
                Url_Song_Message.Text = "";
            }
            else
            {
                Url_Song_Message.Text = "Song url invalid!";
            }
            if (Title_Message.Text == "" && Url_Thumbnail_Mesage.Text == "" && Url_Song_Message.Text == "" && Check_Url_Song(song))
            {
                StorageFile config_login = await ApplicationData.Current.LocalFolder.GetFileAsync("config_login.json");

                JObject data = JObject.Parse(await FileIO.ReadTextAsync(config_login));

                Song songEntity = new Song
                {
                    author    = data.SelectToken("fullname").ToString(),
                    thumbnail = thumbnail,
                    title     = title,
                    url       = song
                };
                var rs = await ApiHandle.Upload_Song(songEntity);

                if (rs.Status == "OK")
                {
                    ContentDialog uploadSuccess = new ContentDialog()
                    {
                        Title           = "Upload success!",
                        CloseButtonText = "Ok"
                    };

                    await uploadSuccess.ShowAsync();
                }
            }
        }