public void HotelManagerUpdate() { ResultsEdit changed = access.AddHotelGuest(TestGuest); //locates the fake record ID int guestID = TestCleanupAccessor.GetHotelGuest(); //pulls from real manager HotelGuest guest = access.GetHotelGuest(guestID); //assigns a new value in guest2 HotelGuest guest2 = new HotelGuest(guest.FirstName, "Individual", guest.Address1, guest.Address2, guest.CityState, guest.PhoneNumber, guest.EmailAddress, guest.Room, guest.GuestPIN, guest.Active); //calls to manager to complete update ResultsEdit edited = access.UpdateHotelGuest(guest, guest2); Assert.AreEqual(ResultsEdit.Success, edited); }
/// <summary> /// Miguel Santana /// Created: 2015/02/16 /// Validate fields and submit data to HotelGuestManager /// </summary> /// <remarks> /// Rose Steffensmeier /// Updated: 2015/03/05 /// Added Room number field /// Pat Banks /// Updated: 2015/04/03 /// added guest pin field /// </remarks> private async void Submit() { if (CurrentHotelGuest != null && ValidateChanged()) { switch (await ShowMessage("No data was changed. Would you like to keep editing?", "Alert", MessageDialogStyle.AffirmativeAndNegative)) { case MessageDialogResult.Affirmative: Close(); break; default: return; } } if (!Validate()) { return; } try { //FormatException found in if loop if (CurrentHotelGuest == null) { Result = _hotelGuestManager.AddHotelGuest( new HotelGuest( TxtFirstName.Text.Trim(), TxtLastName.Text.Trim(), TxtAddress1.Text.Trim(), TxtAddress2.Text.Trim(), (CityState)CboZip.SelectedItem, TxtPhoneNumber.Text.Trim(), TxtEmailAddress.Text.Trim(), TxtRoomNumber.Text.Trim(), TxtGuestPin.Text.Trim() ) ); } else { Result = _hotelGuestManager.UpdateHotelGuest( CurrentHotelGuest, new HotelGuest( TxtFirstName.Text.Trim(), TxtLastName.Text.Trim(), TxtAddress1.Text.Trim(), TxtAddress2.Text.Trim(), (CityState)CboZip.SelectedItem, TxtPhoneNumber.Text.Trim(), TxtEmailAddress.Text.Trim(), TxtRoomNumber.Text.Trim(), TxtGuestPin.Text.Trim() ) ); } if (Result == ResultsEdit.Success) { await ShowMessage("Your Request was Processed Successfully", "Success"); DialogResult = true; Close(); } else { ShowErrorMessage("Error Processing Request", "Error"); } } catch (SqlException ex) { if (ex.Message.Contains("UniqueRoomExceptNulls")) { ShowErrorMessage("A Pin is Already Associated With This Room.", "Error"); } else if (ex.Message.Contains("UniquePINExceptNulls")) { ShowErrorMessage("A Room is Already Associated With This Pin.", "Error"); } else { ShowErrorMessage("There Was An Issue Contacting the Database.", "Error"); } } catch (Exception ex) { ShowErrorMessage(ex); } }