private static void ConfirmReserveButton_Click(object sender, RoutedEventArgs e) { DataModels database = DataModels.GetInstance(); Button button = (Button)sender; List <Object> data = (List <Object>)button.Tag; Calendar datePicker = (Calendar)data[0]; TextBox numberofGuestTextBox = (TextBox)data[1]; RoomsListShowCanvas roomListShowCanvas = (RoomsListShowCanvas)data[2]; int index = (int)data[3]; DateTime startDate = datePicker.SelectedDates[0]; DateTime endDate = datePicker.SelectedDates[datePicker.SelectedDates.Count - 1]; if (!BackEndHelper.IsNumber(numberofGuestTextBox.Text)) { MessageBox.Show("Number of guests must be a number"); return; } int numberOfGuests = int.Parse(numberofGuestTextBox.Text); Room room = roomListShowCanvas.GetSelectedRoom(index); if (numberOfGuests > room.type.maxGuests) { MessageBox.Show("Number of Guests bigger than room capacity"); return; } Booking booking = new Booking(database.GetBookingId(), startDate, endDate, numberOfGuests, GetMainWindow().ActiveUser, roomListShowCanvas.GetSelectedMealPlan(index), room, new Review(database.GetBookingId()), roomListShowCanvas.GetSelectedWebsite(index)); if (database.AddBooking(booking)) { MessageBox.Show("You Booked the room !"); } else { MessageBox.Show("Error"); } }