Ejemplo n.º 1
0
        private async void SignUp(object sender, RoutedEventArgs e)
        {
            try
            {
                this.currentSong.name        = this.Name.Text;
                this.currentSong.description = this.Description.Text;
                this.currentSong.singer      = this.Singer.Text;
                this.currentSong.author      = this.Author.Text;
                this.currentSong.thumbnail   = this.Thumbnail.Text;
                this.currentSong.link        = this.Link.Text;
            }
            catch (Exception ex)
            {
                await ApiHandle.Create_Song(this.currentSong);

                var dialog = new MessageDialog("Upload Success");
                dialog.Title = "Really?";
                dialog.Commands.Add(new UICommand {
                    Label = "Ok", Id = 0
                });
                var res = await dialog.ShowAsync();
            }
            Debug.WriteLine("Action success.");

            if (this.Name.Text == "" && this.Description.Text == "" && this.Singer.Text == "" && this.Author.Text == "" && this.Thumbnail.Text == "" && this.Link.Text == "")
            {
                this.error_Info.Text = "Thông tin không được để trống";
            }
        }
Ejemplo n.º 2
0
        private async void BtnSignup_Click_1(object sender, RoutedEventArgs e)
        {
            // do validate first.
            this.currentSong.name        = this.Name.Text;
            this.currentSong.description = this.Description.Text;
            this.currentSong.singer      = this.Singer.Text;
            this.currentSong.author      = this.Author.Text;
            this.currentSong.thumbnail   = this.Thumbnail.Text;
            this.currentSong.link        = this.Link.Text;
            await ApiHandle.Create_Song(this.currentSong);

            Debug.WriteLine("Action success.");
        }
Ejemplo n.º 3
0
        private async void SignUp(object sender, RoutedEventArgs e)
        {
            Dictionary <String, String> SongInfo = new Dictionary <string, string>();

            SongInfo.Add("singer", this.Singer.Text);
            SongInfo.Add("link", this.Link.Text);

            this.currentSong.name        = this.Name.Text;
            this.currentSong.description = this.Description.Text;
            this.currentSong.singer      = this.Singer.Text;
            this.currentSong.author      = this.Author.Text;
            this.currentSong.thumbnail   = this.Thumbnail.Text;
            this.currentSong.link        = this.Link.Text;
            validatSong();
            await ApiHandle.Create_Song(this.currentSong);

            Debug.WriteLine("Action success.");
        }
Ejemplo n.º 4
0
        private async void Add_Song(object sender, RoutedEventArgs e)
        {
            this.currentSong.name        = NameSong.Text;
            this.currentSong.description = Description.Text;
            this.currentSong.singer      = Singer.Text;
            this.currentSong.author      = Author.Text;
            this.currentSong.thumbnail   = ThumbnailURL.Text;
            this.currentSong.link        = LinkSong.Text;

            var httpResponse = ApiHandle.Create_Song(this.currentSong);

            if (httpResponse.Result.StatusCode == HttpStatusCode.Created)
            {
                var dialog = new Windows.UI.Popups.MessageDialog("You created a new song successfully");
                dialog.Commands.Add(new Windows.UI.Popups.UICommand("Closed")
                {
                    Id = 1
                });
                dialog.CancelCommandIndex = 1;
                await dialog.ShowAsync();
            }
            else
            {
                var errorJson = await httpResponse.Result.Content.ReadAsStringAsync();

                Error errResponse = JsonConvert.DeserializeObject <Error>(errorJson);
                if (errResponse.error.Count > 0)
                {
                    foreach (var errorField in errResponse.error.Keys)
                    {
                        if (this.FindName(errorField) is TextBlock textBlock)
                        {
                            textBlock.Text       = "* " + errResponse.error[errorField];
                            textBlock.Visibility = Visibility.Visible;
                            textBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                        }
                    }
                }
            }
        }