public void TestEditGuestValid()
        {
            //Arrange
            Guest oldGuest = _guests[0];
            Guest newGuest = _guests[0];

            newGuest.MemberID           = 100002;
            newGuest.GuestTypeID        = "Student";
            newGuest.LastName           = "Johnson";
            newGuest.FirstName          = "James";
            newGuest.EmergencyFirstName = "Albus";
            //Act
            _guestManager.EditGuest(newGuest, oldGuest);
            //Assert
            Guest guest = _guestManager.ReadGuestByGuestID(newGuest.GuestID);

            Assert.IsTrue(newGuest.GuestID == guest.GuestID &&
                          newGuest.MemberID == guest.MemberID &&
                          newGuest.FirstName == guest.FirstName &&
                          newGuest.LastName == guest.LastName &&
                          newGuest.Email == guest.Email &&
                          newGuest.PhoneNumber == guest.PhoneNumber &&
                          newGuest.GuestTypeID == guest.GuestTypeID &&
                          newGuest.Minor == guest.Minor &&
                          newGuest.Active == guest.Active &&
                          newGuest.ReceiveTexts == guest.ReceiveTexts &&
                          newGuest.EmergencyFirstName == guest.EmergencyFirstName &&
                          newGuest.EmergencyLastName == guest.EmergencyLastName &&
                          newGuest.EmergencyPhoneNumber == guest.EmergencyPhoneNumber &&
                          newGuest.EmergencyRelation == guest.EmergencyRelation);
        }
예제 #2
0
        /// <summary>
        /// Alisa Roehr
        /// Created: 2019/02/01
        /// Modified: 2019/03/01
        ///
        /// for finishing with the form.
        ///
        /// Updated By: Caitlin Abelson
        /// Date: 2019/04/10
        ///
        /// Changed the memberID so that is now reflected the new combobox that needed to be added.
        /// The combobox will have the memberID if it's an update and the user will able to choose
        /// from a list of members if it's a new guest being made.
        ///
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnGuestAction_Click(object sender, RoutedEventArgs e)
        {
            string phoneNumber = txtPhoneNumber.Text;

            phoneNumber.Trim('-', '(', ')', ' ');
            string EMphoneNumber = txtEmerPhone.Text;

            EMphoneNumber.Trim('-', '(', ')', ' ');
            if (btnGuestAction.Content == "Add")
            {
                if (ValidateInfo())
                {
                    _newGuest = new Guest();

                    _newGuest.MemberID             = _members.ElementAt(cbxMemberName.SelectedIndex).MemberID;
                    _newGuest.GuestTypeID          = (string)cboGuestType.SelectedValue;
                    _newGuest.FirstName            = txtFirstName.Text;
                    _newGuest.LastName             = txtLastName.Text;
                    _newGuest.PhoneNumber          = phoneNumber;
                    _newGuest.Email                = txtEmail.Text;
                    _newGuest.Minor                = (bool)chkMinor.IsChecked;
                    _newGuest.ReceiveTexts         = (bool)chkTexting.IsChecked;
                    _newGuest.EmergencyFirstName   = txtEmerFirst.Text;
                    _newGuest.EmergencyLastName    = txtEmerLast.Text;
                    _newGuest.EmergencyPhoneNumber = EMphoneNumber;
                    _newGuest.EmergencyRelation    = txtEmerRelat.Text;

                    try
                    {
                        _guestManager.CreateGuest(_newGuest);
                        this.DialogResult = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Add Guest Failed!");
                    }
                }

                /*else
                 * {
                 *  MessageBox.Show("Not filled out fully. Fill out boxes next to the X's and try again.");
                 * }*/
            }
            else
            {
                if (btnGuestAction.Content == "Edit")
                {
                    // change from read only to edit
                    setEditable();
                    cbxMemberName.IsEnabled = false;
                    btnGuestAction.Content  = "Save";
                }
                else if (btnGuestAction.Content == "Save")
                {
                    if (ValidateInfo())
                    {
                        _newGuest = new Guest()
                        {
                            GuestID              = int.Parse(Title),
                            MemberID             = _members.ElementAt(cbxMemberName.SelectedIndex).MemberID,
                            GuestTypeID          = (string)cboGuestType.SelectedValue,
                            FirstName            = txtFirstName.Text,
                            LastName             = txtLastName.Text,
                            PhoneNumber          = phoneNumber,
                            Email                = txtEmail.Text,
                            Minor                = (bool)chkMinor.IsChecked,
                            Active               = _oldGuest.Active,
                            ReceiveTexts         = (bool)chkTexting.IsChecked,
                            EmergencyFirstName   = txtEmerFirst.Text,
                            EmergencyLastName    = txtEmerLast.Text,
                            EmergencyPhoneNumber = EMphoneNumber,
                            EmergencyRelation    = txtEmerRelat.Text,
                            CheckedIn            = _oldGuest.CheckedIn
                        };
                        try
                        {
                            _guestManager.EditGuest(_newGuest, _oldGuest);
                            this.DialogResult = true;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Save Guest Failed!");
                        }
                    }

                    /* else
                     * {
                     *   MessageBox.Show("Not filled out fully. Fill out boxes next to the X's and try again.");
                     * }*/
                }
                else
                {
                    this.DialogResult = true;
                }
            }
        }