Exemplo n.º 1
0
        private void AddGift(object sender, RoutedEventArgs e)
        {
            string name         = this.giftName?.Text;
            string price        = this.giftPrice?.Text;
            string description  = this.giftDescription?.Text;
            string errorMessage = GiftManager.HasInvalidGiftTextFields(name, price);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                MessageBox.Show(errorMessage);
                return;
            }
            bool added = GiftManager.AddGift(name, price, description);

            if (added)
            {
                ShowGiftAddedBalloonNotification(name, price, description);
                this.ClearAllFields();
            }
            else
            {
                MessageBox.Show($"An error occurred, and {name} could not be added", "Error adding Gift", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
 public void TestHasInvalidGiftTextFields(string name, string price, string result)
 {
     Assert.Equal(result, GiftManager.HasInvalidGiftTextFields(name, price));
 }