public void CreateGift() { if (currentGiftManager != null) { currentGiftManager.AddGift(); } }
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); } }
public void TestAddGift(string name, string price, string description, bool result) { Assert.Equal(result, GiftManager.AddGift(name, price, description)); }