Пример #1
0
 public void CreateGift()
 {
     if (currentGiftManager != null)
     {
         currentGiftManager.AddGift();
     }
 }
Пример #2
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);
            }
        }
Пример #3
0
 public void TestAddGift(string name, string price, string description, bool result)
 {
     Assert.Equal(result, GiftManager.AddGift(name, price, description));
 }