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); }
/// <summary> /// Ryan Blake /// Created: 2015/03/06 /// Allows user to edit a booking /// </summary> /// <param name="invoiceToEdit">Invoice info from the view invoice UI</param> /// <param name="inBookingDetails">Booking info from the view invoice UI</param> /// <param name="readOnly">Make the form ReadOnly.</param> /// <exception cref="WanderingTurtleException">Occurs making components readonly.</exception> public EditBooking(InvoiceDetails invoiceToEdit, BookingDetails inBookingDetails, bool readOnly = false) { CurrentInvoice = invoiceToEdit; CurrentBookingDetails = inBookingDetails; InitializeComponent(); Title = "Editing Booking: " + CurrentBookingDetails.EventItemName; PopulateTextFields(); _eId = (int)Globals.UserToken.EmployeeID; if (readOnly) { (Content as Panel).MakeReadOnly(BtnCancel); } }
public void InvoiceManagerCalculateDue() { //Updated: Create a list of booking details List<BookingDetails> guestBookings = new List<BookingDetails>(); //Creates two fake Total Charges to be added to the guestBookings list BookingDetails test = new BookingDetails(); test.TotalCharge = 40m; BookingDetails test2 = new BookingDetails(); test2.TotalCharge = 50m; //Fake BookingDetails added guestBookings.Add(test); guestBookings.Add(test2); //Calculates by calling manager method to test decimal amount = access.CalculateTotalDue(guestBookings); //Asserts that 90 will be returned. Assert.AreEqual((decimal)90, amount); }
public void InvoiceManagerCheckArchiveInvoice() { //Grabs the fake guest ID int id = TestCleanupAccessor.GetHotelGuest(); //Retrieves the invoice for the guest Invoice invoice = access.RetrieveInvoiceByGuest(id); InvoiceDetails invoice2 = (InvoiceDetails)invoice; //creates a list of BookingDetails List<BookingDetails> fakeBookings = new List<BookingDetails>(); //Creates a bookingDetails object and adds a date and quantity to it. BookingDetails booking = new BookingDetails(); DateTime date = new DateTime(2020,05,01); booking.StartDate = date; booking.Quantity = 0; //Adds it to the list fakeBookings.Add(booking); //checks to archive var result = access.CheckToArchiveInvoice(invoice2, fakeBookings); //Asserts it will be a success Assert.AreEqual(ResultsArchive.OkToArchive, result); }
/// <summary> /// Pat Banks /// Created: 2015/02/25 /// Creates a connection with database and /// calls the stored procedure spSelectInvoiceBookings /// that querys the database for all bookings of a specified hotel guest /// </summary> /// <param name="GuestID">A Hotel Guest's ID</param> /// <returns>List of Booking details for a guest</returns> public static List<BookingDetails> GetInvoiceBookingsByGuest(int guestID) { //create list of bookingdetails List<BookingDetails> guestBookings = new List<BookingDetails>(); var conn = DatabaseConnection.GetDatabaseConnection(); string sql = @"spSelectInvoiceBookings"; SqlCommand command = new SqlCommand(sql, conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@hotelGuestID", guestID); //connect to db and retrieve information try { conn.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows == true) { while (reader.Read()) { var details = new BookingDetails(); details.BookingID = reader.GetInt32(0); details.GuestID = reader.GetInt32(1); details.EmployeeID = reader.GetInt32(2); details.ItemListID = reader.GetInt32(3); details.Quantity = reader.GetInt32(4); details.DateBooked = reader.GetDateTime(5); details.Discount = reader.GetDecimal(6); details.Active = reader.GetBoolean(7); details.TicketPrice = reader.GetDecimal(8); details.ExtendedPrice = reader.GetDecimal(9); details.TotalCharge = reader.GetDecimal(10); details.StartDate = reader.GetDateTime(11); details.EventItemName = reader.GetString(12); guestBookings.Add(details); } } } catch (Exception ex) { throw ex; } return guestBookings; }
/// <summary> /// Miguel Santana /// Created: 2015/04/06 /// added read-only capability to the ui /// </summary> /// <param name="selectedItem"></param> /// <param name="readOnly"></param> private void OpenBookingDetail(BookingDetails selectedItem = null, bool readOnly = false) { try { if (selectedItem == null) { if (new AddBooking(CurrentInvoice).ShowDialog() == false) return; RefreshBookingList(); } else { if (readOnly) { new EditBooking(CurrentInvoice, selectedItem, true).ShowDialog(); return; } //check if selected item can be edited switch (_bookingManager.CheckToEditBooking(selectedItem)) { case (ResultsEdit.CannotEditTooOld): throw new WanderingTurtleException(this, "Bookings in the past cannot be edited."); case (ResultsEdit.Cancelled): throw new WanderingTurtleException(this, "This booking has been cancelled and cannot be edited."); case (ResultsEdit.OkToEdit): if (new EditBooking(CurrentInvoice, selectedItem).ShowDialog() == false) return; RefreshBookingList(); break; } } } catch (Exception ex) { throw new WanderingTurtleException(this, ex); } }
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> /// Pat Banks /// Created: 2015/03/19 /// /// Gives the results of cancelling a booking to the preseantation layer /// </summary> /// <param name="bookingToCancel">The bookingDetails object to cancel</param> /// <returns>An enumerated result depicting pass or fail</returns> public ResultsEdit CancelBookingResults(BookingDetails bookingToCancel) { try { //update the numbers bookingToCancel.Quantity = 0; bookingToCancel.TicketPrice = 0; bookingToCancel.ExtendedPrice = 0; bookingToCancel.Discount = 0; int result = EditBooking(bookingToCancel); //result should be 2 - one for the booking, one to update the number of guests for the item listing if (result == 2) { //refresh Data Cache RefreshItemListingDetailsListCacheData(); return ResultsEdit.Success; } return ResultsEdit.ChangedByOtherUser; } catch (Exception ex) { throw ex; } }
/// <summary> /// Pat Banks /// Created: 2015/03/19 /// /// Checks if a booking can be edited by performing logical checks if booking is too old or cancelled /// </summary> /// <param name="bookingToCheck">The BookingDetails object to crossreference against</param> /// <returns>An enumerated result depicting pass or fail</returns> public ResultsEdit CheckToEditBooking(BookingDetails bookingToCheck) { if (bookingToCheck.StartDate < DateTime.Now) { return ResultsEdit.CannotEditTooOld; } return bookingToCheck.Quantity == 0 ? ResultsEdit.Cancelled : ResultsEdit.OkToEdit; }
/// <summary> /// Tony Noel /// Created: 2015/03/04 /// /// A method to compare two different dates and determine a cancellation fee amount. /// Stores today's date, then subtracts todays date from the start date of the event /// Uses a TimeSpan object which represents an interval of time and is able to perform calculations on time. /// The difference of days is stored on an double and used to test conditions. /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/03/07 /// Tony Noel /// Updated: 2015/03/10 /// </remarks> /// <param name="bookingStartTime">The BookingDetails being refunded for</param> /// <returns>Decimal containing the total cancellation fee % amount</returns> public decimal CalculateTime(BookingDetails bookingStartTime) { decimal feePercent; //TimeSpan is used to calculate date differences TimeSpan ts = bookingStartTime.StartDate - DateTime.Now; //The .TotalDays gets the amount of days inbetween returns a double to account for partial days double difference = ts.TotalDays; //if event is more than 3 days away, there is no fee charged if (difference >= 3) { feePercent = 0m; } //if event is between 1 and 3 days, 1/2 the total price is charged else if (difference < 3 && difference > 1) { feePercent = 0.5m; } //if event is less than 1 day away, guest pays for entire amount else { feePercent = 1.0m; } return feePercent; }
/// <summary> /// Tony Noel /// Updated: 2015/03/10 /// /// Method to calculate the cancellation fee using the CalculateTime method * TotalCharge /// </summary> /// <param name="bookingToCancel">The BookingDetails object to be cancelled</param> /// <returns>the actual fee in $ that will be charged for cancelling a booking</returns> public decimal CalculateCancellationFee(BookingDetails bookingToCancel) { decimal feePercent = CalculateTime(bookingToCancel); return feePercent * bookingToCancel.TotalCharge; }
public void TestBookingCalculateTimeFeeHalf() { //Creates a Bookingdetails object to pass to BookingManager to check calculation of CalculateTime BookingDetails bookingD = new BookingDetails(); DateTime today = DateTime.Now; DateTime value = today.AddDays(2); bookingD.StartDate = value; decimal result = myBook.CalculateTime(bookingD); decimal expected = .5m; //Asserts that the expected and the result will be .5M Assert.AreEqual(expected, result); }
public void TestBookingCalculateTimeFee1() { //Creates a Bookingdetails object to pass to BookingManager to check calculation of CalculateTime BookingDetails bookingD = new BookingDetails(); DateTime value = new DateTime(2000, 01, 31, 17, 30, 00); bookingD.StartDate = value; decimal result = myBook.CalculateTime(bookingD); decimal expected = 1.0m; //Asserts that the expected and the result will be 1.0M Assert.AreEqual(expected, result); }
public void TestBookingCalcCancellationFee() { //Creates a bookingDetails object used to perform calculations. Method uses the TotalCharge and the startdate BookingDetails bookingD = new BookingDetails(); DateTime value = new DateTime(2000, 01, 31); bookingD.StartDate = value; bookingD.TotalCharge = 3.0m; decimal expected = 3.0m; decimal result = myBook.CalculateCancellationFee(bookingD); //Asserts that the expected and the result will be .5M Assert.AreEqual(expected, result); }