private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            short type   = (short)mealTypeComboBox.SelectedIndex;
            bool  result = RestClient.Instance.MakePostRequest("EatMeal", new MealData()
            {
                UserLogin  = RestClient.Instance.LoggedUserLogin,
                Weigth     = 1,
                MealType   = type,
                DishesList = addedDishes
            });
            string userResponse = result ? "Udało się dodać posiłek" : "Nie możemy dodać posiłku";

            if (result)
            {
                Window mainWindow = new MainAppWindow();
                App.Current.MainWindow = mainWindow;
                mainWindow.Show();
                this.Close();
            }

            MessageBox.Show(userResponse,
                            "Dodawanie posiłku",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information);
        }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool result = RestClient.Instance.MakePostRequest("TryCreateComponent", new Component()
            {
                Name                = nameTextBox.Text,
                Manufacturer        = manufacturerTextBox.Text,
                CaloriesIn100g      = Int32.Parse(CaloriesTextBox.Text),
                ProteinIn100g       = Int32.Parse(ProteinsTextBox.Text),
                FatsIn100g          = Int32.Parse(FatsTextBox.Text),
                CarbohydratesIn100g = Int32.Parse(CarbohydratesTextBox.Text)
            });
            string userResponse = result ? "Udało się dodać składnik" : "Nie możemy dodać wskazanego składnika";

            if (addOneMoreCheckBox.IsChecked.Equals(false))
            {
                Window mainWindow = new MainAppWindow();
                App.Current.MainWindow = mainWindow;
                mainWindow.Show();
                this.Close();
            }
            else
            {
                nameTextBox.Clear();
                manufacturerTextBox.Clear();
                CaloriesTextBox.Clear();
            }

            MessageBox.Show(userResponse,
                            "Dodawanie składnika",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information);
        }
        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Window mainWindow = new MainAppWindow();

            App.Current.MainWindow = mainWindow;
            mainWindow.Show();
            this.Close();
        }
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            bool result = RestClient.Instance.MakePostRequest("TryCreateDish", new DishData()
            {
                UserLogin      = RestClient.Instance.LoggedUserLogin,
                Name           = nameTextBox.Text,
                ComponentsList = selectedComponentsList
            });
            string userResponse = result ? "Udało się dodać danie" : "Nie możemy dodać wskazanego dania";

            if (result)
            {
                Window mainWindow = new MainAppWindow();
                App.Current.MainWindow = mainWindow;
                mainWindow.Show();
                this.Close();
            }

            MessageBox.Show(userResponse,
                            "Dodawanie potrawy",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            short type = (short)genderComboBox.SelectedIndex;

            bool result = RestClient.Instance.MakePostRequest("UpdateUserInfo", new UserInfo()
            {
                UserLogin = RestClient.Instance.LoggedUserLogin,
                Age       = Int32.Parse(ageTextBox.Text),
                Weight    = Int32.Parse(weightTextBox.Text),
                Growth    = Int32.Parse(growthTextBox.Text),
                Gender    = type
            });
            string userResponse = result ? "Zapisano dane" : "Nie możemy zapisać danych";

            if (result)
            {
                Window window = null;
                if (UpdateAfterRegister)
                {
                    RestClient.Instance.LoggedUserLogin = null;
                    window = new LoginWindow();
                    ((LoginWindow)window).SetVisibilitySuccLoginLabel(Visibility.Visible);
                }
                else
                {
                    window = new MainAppWindow();
                }
                App.Current.MainWindow = window;
                window.Show();
                this.Close();
            }

            MessageBox.Show(userResponse,
                            "Uzepełnianie danych użytkownika",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information);
        }