public void TestCancelBookingResults() { //Tests the Cancel Booking Results method in the Booking Manager- which takes a BookingDetails object. //Grabs the ID for the dummy booking int id = TestCleanupAccessor.GetBooking(); //retrieves the full booking information Booking booking1 = myBook.RetrieveBooking(id); //Creates a BookingDetails object and assigns variables from the booking to it. bookingDetails = new BookingDetails(); bookingDetails.BookingID = id; bookingDetails.GuestID = guestID; bookingDetails.EmployeeID = empID; bookingDetails.ItemListID = itemID; bookingDetails.Quantity = bQuantity; bookingDetails.DateBooked = dateBooked; bookingDetails.TicketPrice = ticket; bookingDetails.ExtendedPrice = extended; bookingDetails.Discount = discount; bookingDetails.TotalCharge = total; //Passes the object to the CancelBookingResults method and asserts that that cancel will be successful ResultsEdit result = myBook.CancelBookingResults(bookingDetails); ResultsEdit expected = ResultsEdit.Success; Assert.AreEqual(expected, result); }
/// <summary> /// Ryan Blake /// Created: 2015/03/06 /// To check if the quantity is going up and see if the booking is already full /// </summary> /// <remarks> /// Tony Noel /// Updated: 2015/03/10 /// if the booking has occured already, it cannot be changed. /// /// Pat Banks /// Updated: 2015/03/11 /// up/down controls added for quantity and discount /// /// Pat Banks /// Updated: 2015/03/19 /// Moved decision logic to booking manager /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private async void btnSubmitBooking_Click(object sender, RoutedEventArgs e) { try { //get form info Booking editedBookingRecord = GatherFormInformation(); //get results of adding booking ResultsEdit result = _bookingManager.EditBookingResult(CurrentBookingDetails.Quantity, editedBookingRecord); switch (result) { case (ResultsEdit.QuantityZero): throw new ApplicationException("Please use cancel instead of setting quantity 0."); case (ResultsEdit.Success): await this.ShowMessageDialog(string.Format("The booking has been successfully {0}.", CurrentBookingDetails == null ? "added" : "updated")); DialogResult = true; Close(); break; case (ResultsEdit.ListingFull): throw new ApplicationException("This event is already full. You cannot add more guests to it."); case (ResultsEdit.ChangedByOtherUser): throw new ApplicationException("Changed by another user"); } } catch (Exception ex) { throw new WanderingTurtleException(this, ex); } }
/// <summary> /// Tony Noel /// Created: 2015/03/04 /// A method to cancel a booking. /// The object is then sent to the OrderManager-EditBooking method to be processed. /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/03/08 /// Updated fields to reflect cancellation of booking /// /// Pat Banks /// Updated: 2015/03/19 /// Moved logic to BookingManager - CancelBookingResults /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private async void BtnConfirmCancel_Click(object sender, RoutedEventArgs e) { try { //get the cancellation fee CurrentBooking.TotalCharge = _cancelFee; //cancel booking and get results ResultsEdit result = _bookingManager.CancelBookingResults(CurrentBooking); switch (result) { case (ResultsEdit.ChangedByOtherUser): throw new ApplicationException("This booking has already been cancelled."); case (ResultsEdit.Success): await this.ShowMessageDialog("Booking successfully cancelled."); DialogResult = true; Close(); break; } } catch (Exception ex) { throw new WanderingTurtleException(this, ex); } }
/// <summary> /// Miguel Santana /// Created: 2015/02/20 /// Validates and Updates Employee user /// </summary> /// <remarks> /// Tony Noel /// Updated: 2015/04/13 /// Updated to comply with the ResultsEdit class of error codes. /// </remarks> private async void EmployeeUpdate() { if (!Validate()) { return; } try { Debug.Assert(ChkActiveEmployee.IsChecked != null, "ChkActiveEmployee.IsChecked != null"); ResultsEdit result = _employeeManager.EditCurrentEmployee( CurrentEmployee, new Employee( TxtFirstName.Text, TxtLastName.Text, !string.IsNullOrEmpty(TxtPassword.Password) ? TxtPassword.Password : null, (int)CboUserLevel.SelectedItem, ChkActiveEmployee.IsChecked.Value ) ); if (result == ResultsEdit.Success) { await ShowMessage("Employee updated successfully"); //closes window after successful add DialogResult = true; Close(); } } catch (Exception ax) { ShowErrorMessage(ax); } }
/// <summary> /// Pat Banks /// created: 2015/04/22 /// Need confirmation from guest before can officially submit the booking /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnConfirm_Click(object sender, EventArgs e) { Booking webBookingToAdd = new Booking((int)foundGuest.HotelGuestID, 100, selectedItemListing.ItemListID, ticketQty, DateTime.Now, selectedItemListing.Price, extendedPrice, discount, totalPrice); ResultsEdit addResult = myManager.AddBookingResult(webBookingToAdd); switch (addResult) { case ResultsEdit.Success: showError("Thank You, " + foundGuest.GetFullName + ". <br>You have successfully signed up for:\n" + selectedItemListing.EventName + "."); clearFields(); gvListings.DataBind(); confirmDetails.Style.Add("display", "none"); ticketRequest.Style.Add("display", "block"); break; case ResultsEdit.ListingFull: showError("Sorry, that event is full!"); break; case ResultsEdit.DatabaseError: showError("Sorry, there was a problem registering for this event.\nPlease contact the front desk."); break; } }
public void HotelManagerAdd() { //Assigns a Results Edit object after attempting to add the TestGuest into the database ResultsEdit changed = access.AddHotelGuest(TestGuest); //Asserts that the add will be successful. Assert.AreEqual(ResultsEdit.Success, changed); }
public void CheckToEditBooking() { //Checks the edit booking and makes sure a result is returned. bookingDetails = new BookingDetails(); bookingDetails.StartDate = DateTime.Now; bookingDetails.Quantity = 2; ResultsEdit result = myBook.CheckToEditBooking(bookingDetails); Assert.IsNotNull(result); }
public void TestAddBookingResult() { //booking object created TestBookingConstructor(); ResultsEdit result = myBook.AddBookingResult(booking); ResultsEdit expected = ResultsEdit.Success; Assert.AreEqual(expected, result); }
public void EmployeeManagerAddEmployee() { //Adds fake employee to Data base bool worked = false; ResultsEdit result = myManager.AddNewEmployee(testEmp); if (result == ResultsEdit.Success) { worked = true; } Assert.IsTrue(worked); }
public void TestEditBookingResultsListingFull() { //grabs the BookingID from the first booking from the active bookings list int id = getThem[getThem.Count - 1].BookingID; Booking booking1 = myBook.RetrieveBooking(id); //Retrieves int original = booking1.Quantity; booking1.Quantity = 10000;//sets to new quantity ////Passes the object to the EditBookingResults method and asserts that that result will be full ResultsEdit result = myBook.EditBookingResult(original, booking1); ResultsEdit expected = ResultsEdit.ListingFull; Assert.AreEqual(expected, result); }
public void EmployeeManagerEditEmployee() { //Grabs the fake emp id int ID = TestCleanupAccessor.getTestEmp(); //Gets the entire Employee Record Employee orig = EmployeeAccessor.GetEmployee(ID); //Creates a new employee object with the original properties, update the active property to false. Employee newEmp = new Employee(orig.FirstName, orig.LastName, orig.Password, (int)orig.Level, false); //calls to manager. ResultsEdit result = myManager.EditCurrentEmployee(orig, newEmp); //Asserts that the update went through Assert.AreEqual(ResultsEdit.Success, result); }
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); }
public void TestEditBookingResultsSuccess() { //Grabs the List of all active bookings in DB and assigns the first record from the listing to a int id int id = getThem[getThem.Count - 1].BookingID; //retrieves the full booking information, assigns the initial quantity to an int //Does not change the record, just checks to make sure all steps going through. Booking booking1 = myBook.RetrieveBooking(id); int original = booking1.Quantity; //Passes the object to the EditBookingResults method and asserts that that result will be successful ResultsEdit result = myBook.EditBookingResult(original, booking1); ResultsEdit expected = ResultsEdit.Success; Assert.AreEqual(expected, result); }
public void TestEditBookingResultsQuantityZero() { //Tests the Edit Booking Results method in the Booking Manager- which takes an int and a Booking object. //Grabs the ID for the dummy booking int id = getThem[getThem.Count - 1].BookingID; //retrieves the full booking information, assigns the initial quantity to an int Booking booking1 = myBook.RetrieveBooking(id); int original = booking1.Quantity; booking1.Quantity = 0; //Passes the object to the EditBookingResults method and asserts that that result will be 0 ResultsEdit result = myBook.EditBookingResult(original, booking1); ResultsEdit expected = ResultsEdit.QuantityZero; Assert.AreEqual(expected, result); }
public void TestEditBookingResultsListingFull() { //Tests the Edit Booking Results method in the Booking Manager- which takes an int and a Booking object. //Grabs the ID for the dummy booking int id = TestCleanupAccessor.GetBooking(); //retrieves the full booking information, assigns the initial quantity to an int, then reassigns the object quantity //to a new amount Booking booking1 = myBook.RetrieveBooking(id); int original = booking1.Quantity; booking1.Quantity = 30; //Passes the object to the EditBookingResults method and asserts that that result will be full ResultsEdit result = myBook.EditBookingResult(original, booking1); ResultsEdit expected = ResultsEdit.ListingFull; Assert.AreEqual(expected, result); }
/// <summary> /// Tony Noel /// Created: 2015/03/20 /// UI to confirm details for cancelling a booking /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/03/19 /// Moved logic checks to invoice manager - checkToArchiveInvoice /// </remarks> private void CancelBooking() { //check if something was selected if (LvGuestBookings.SelectedItem == null) { throw new WanderingTurtleException(this, "Please select a booking to cancel."); } //check if selected item can be cancelled ResultsEdit result = _bookingManager.CheckToEditBooking((BookingDetails)LvGuestBookings.SelectedItem); switch (result) { case (ResultsEdit.CannotEditTooOld): throw new WanderingTurtleException(this, "Bookings in the past cannot be cancelled.", "Warning"); case (ResultsEdit.Cancelled): throw new WanderingTurtleException(this, "This booking has already been cancelled.", "Warning"); case (ResultsEdit.OkToEdit): try { //opens the ui and passes the booking details object in CancelBooking cancel = new CancelBooking((BookingDetails)LvGuestBookings.SelectedItem, CurrentInvoice); if (cancel.ShowDialog() == false) { return; } RefreshBookingList(); } catch (Exception ex) { throw new WanderingTurtleException(this, ex); } break; } }
/// <summary> /// Tony Noel /// Created: 2015/02/13 /// Handles the add Booking click event /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/03/19 /// Moved decision logic to Booking Manager /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private async void btnAddBookingAdd_Click(object sender, RoutedEventArgs e) { //validates data from form if (!Validate()) { return; } try { Booking bookingToAdd = GatherFormInformation(); //get results of adding booking ResultsEdit result = _bookingManager.AddBookingResult(bookingToAdd); switch (result) { case (ResultsEdit.QuantityZero): throw new WanderingTurtleException(this, "Quantity of tickets must be more than zero."); case (ResultsEdit.DatabaseError): throw new WanderingTurtleException(this, "Booking could not be added due to database malfunction."); case (ResultsEdit.Success): BtnAddBookingAdd.IsEnabled = false; await this.ShowMessageDialog("The booking has been successfully added."); DialogResult = true; Close(); break; } } catch (Exception ex) { throw new WanderingTurtleException(this, ex); } }
/// <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); } }
/// <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); } }
public void AddBookingResult() { ResultsEdit result = myBook.AddBookingResult(booking); }
public void addEmp() { ResultsEdit result = myManager.AddNewEmployee(testEmp); }