Ejemplo n.º 1
0
        private async void EditStar_ButtonClick(object sender, RoutedEventArgs e)
        {
            if (CustomerCbox.SelectedItem as Star != null)
            {
                StarEditingWindow win = new StarEditingWindow(CustomerCbox.SelectedItem as Star);
                if (win.ShowDialog() == true)
                {
                    RestService restService = new RestService("https://webapi20210607153930.azurewebsites.net/", "/Star", token);

                    if (win.Star.StarID == null || win.Star.StarID == string.Empty)
                    {
                        win.Star.StarID = Guid.NewGuid().ToString();
                    }

                    restService.Put <string, Star>((CustomerCbox.SelectedItem as Star).StarID, win.Star);
                    MessageBox.Show("Star updated in the database");

                    await this.GetStarNames();

                    await this.RefreshPlanetList();
                }
                else
                {
                    MessageBox.Show("Modifying selected star was not successful");
                }
            }
            else
            {
                MessageBox.Show("Could not modify selected star.");
            }
        }
Ejemplo n.º 2
0
        private async void AddNewStar_ButtonClick(object sender, RoutedEventArgs e)
        {
            StarEditingWindow win = new StarEditingWindow();

            if (win.ShowDialog() == true)
            {
                RestService restService = new RestService("https://webapi20210607153930.azurewebsites.net/", "/Star", token);

                if (win.Star.StarID == null || win.Star.StarID == string.Empty)
                {
                    win.Star.StarID = Guid.NewGuid().ToString();
                }

                restService.Post <Star>(win.Star);
                MessageBox.Show("Star added to database");

                await this.GetStarNames();

                await this.RefreshPlanetList();
            }
            else
            {
                MessageBox.Show("Adding new star was not successful");
            }
        }