public void EditGuest() { ValidateEmail ve = new ValidateEmail(); if (name.Length == 0) { MessageBox.Show("Please enter a name."); } else if (!ve.IsValidEmail(email)) { MessageBox.Show("Please enter a valid email."); } else if (phoneNumber.Length < 5) { MessageBox.Show("Please enter a valid phone number"); } else if (adminName.Length == 0) { MessageBox.Show("Please enter an admin name."); } else if (!ve.IsValidEmail(adminEmail)) { MessageBox.Show("Please enter a valid admin email."); } else if (adminPhoneNumber.Length < 5) { MessageBox.Show("Please enter a valid admin phone number"); } else { LunchClubGuest em = file.guests.First(m => m.name.Equals(editGuest.name)); em.name = this.name; em.email = this.email; em.phoneNumber = this.phoneNumber; em.diet = this.diet; em.adminName = this.adminName; em.adminEmail = this.adminEmail; em.adminPhoneNumber = this.adminPhoneNumber; file.Save(); OnRequestClose(null); } }
private void EditGuest() { if (selectedGuest != null) { LunchClubGuest guest = file.guests.First(m => m.name.Equals(selectedGuest.name)); editModel.name = guest.name; editModel.email = guest.email; editModel.phoneNumber = guest.phoneNumber; editModel.adminName = guest.adminName; editModel.adminEmail = guest.adminEmail; editModel.adminPhoneNumber = guest.adminPhoneNumber; editModel.diet = guest.diet; editModel.editGuest = guest; AddSpecialGuest newGuestView = new AddSpecialGuest(editModel); newGuestView.Show(); PropertyChanged(this, new PropertyChangedEventArgs("guestList")); } else { MessageBox.Show("Please select a guest to edit first."); } }