private void SubmitButton_Click(object sender, EventArgs e) { DialogResult result = default(DialogResult); switch (myState) { case "add": currentBooking = PopulateBooking(); double newAmount = accountDB.newAmount(currentBooking.Date, currentBooking.EndDate); int index = accountDB.FindIndex(currentBooking.Guest.GuestID); accountDB.AllAccounts[index].AmountDue += newAmount; bookingController.Add(currentBooking); bookingController.makeBooking(currentBooking.Date, currentBooking.EndDate, currentBooking.Room); setUpBookingListView(); guests = guestController.AllGuests; messageTextBox.Text = ""; FormDisplay("view"); break; case "edit": currentBooking = PopulateBooking(); int index1 = currentBooking.BookingRef; double oldAmt = accountDB.oldAmt(index1); int index2 = accountDB.FindIndex(currentBooking.Guest.GuestID); accountDB.AllAccounts[index2].AmountDue -= oldAmt; if (accountDB.AllAccounts[index2].AmountDue < 0) { accountDB.AllAccounts[index2].AmountDue = 0; } newAmount = accountDB.newAmount(currentBooking.Date, currentBooking.EndDate); index = accountDB.FindIndex(currentBooking.Guest.GuestID); accountDB.AllAccounts[index].AmountDue += newAmount; bookingController.Edit(currentBooking); bookingController.makeBooking(currentBooking.Date, currentBooking.EndDate, currentBooking.Room); setUpBookingListView(); messageTextBox.Text = ""; FormDisplay("view"); break; } }
public async void ANewCustomerShouldBeAddedToTheSystemThroughAValidBooking() { var car = await carsController.Index(1); var booking = new Booking { Customer = new Customer() { IdentityNumber = "123456-1234" }, Car = car, PickUpRegistration = new Registration { RegistrationType = RegistrationType.PickUp, DateTime = DateTime.Now, DistanceMeter = car.DistanceMeter } }; var result = await bookingController.Add(booking); Assert.True(result, "A new customer should be added to the system through a valid booking"); }