public void TestCreateGuestValidInput()
        {
            //Arrange
            Guest guest = new Guest()
            {
                GuestID = 100010, MemberID = 100002, GuestTypeID = "Student", FirstName = "Johnny", LastName = "Johnson", PhoneNumber = "3192968018", Minor = true, Active = true, Email = "*****@*****.**", ReceiveTexts = true, EmergencyFirstName = "Albion", EmergencyLastName = "Bumblebee", EmergencyPhoneNumber = "3192885567", EmergencyRelation = "Brother-in-law"
            };

            //Act
            _guestManager.CreateGuest(guest);
            //Assert
            _guests = _guestManager.ReadAllGuests();

            Assert.IsNotNull(_guests.Find(x => x.GuestID == guest.GuestID &&
                                          x.MemberID == guest.MemberID &&
                                          x.FirstName == guest.FirstName &&
                                          x.LastName == guest.LastName &&
                                          x.Email == guest.Email &&
                                          x.PhoneNumber == guest.PhoneNumber &&
                                          x.GuestTypeID == guest.GuestTypeID &&
                                          x.Minor == guest.Minor &&
                                          x.Active == guest.Active &&
                                          x.ReceiveTexts == guest.ReceiveTexts &&
                                          x.EmergencyFirstName == guest.EmergencyFirstName &&
                                          x.EmergencyLastName == guest.EmergencyLastName &&
                                          x.EmergencyPhoneNumber == guest.EmergencyPhoneNumber &&
                                          x.EmergencyRelation == guest.EmergencyRelation));
        }
Exemplo n.º 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;
                }
            }
        }