예제 #1
0
        private void AddGuest_Click(object sender, RoutedEventArgs e)
        {
            if (!NullCheckUtility.IsNotNull(party))
            {
                MessageBox.Show("Please enter total number of guests and costs per person, and click create a list");
            }
            else
            {
                var firstname = ChristianNameTextbox.Text;
                var lastname  = surnameTextbox.Text;

                if (!string.IsNullOrEmpty(firstname) && !string.IsNullOrEmpty(lastname))
                {
                    string message;
                    var    guestWasAddedToList = party.AddToGuestList(firstname, lastname, out message);
                    if (!guestWasAddedToList)
                    {
                        MessageBox.Show(message);
                        AddGuest.IsEnabled = false;
                    }
                    else
                    {
                        var guestlist = party.GetGuestList();
                        guestListListBox.Items.Clear();
                        foreach (var guest in guestlist)
                        {
                            guestListListBox.Items.Add(guest);
                        }
                        totalCostToDisplayAsLabel.Content = party.CostPerCapita * party.NumberOfGuests();

                        totalNumberOfGuestsToDisplayAsLabel.Content = party.NumberOfGuests();
                        changeButton.IsEnabled = true;
                        deleteButton.IsEnabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a first and last name");
                }
            }
        }