예제 #1
0
        private void ButtonBook_Click(object sender, RoutedEventArgs e)
        {
            if (CourseID.SelectedItem != null && StudentID.SelectedItem != null && lblSelectedDate.Content != null)
            {
                int    studentID             = int.Parse(StudentID.Text);
                int    courseID              = int.Parse(CourseID.Text);
                string selectedDate          = lblSelectedDate.Content.ToString();
                bool   checkDuplicateBooking = _bookingManager.DuplicateBookingRecord(studentID, selectedDate);

                if (checkDuplicateBooking)
                {
                    MessageBox.Show("Student already have a class booked for this date", "Duplicate booking", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    _bookingManager.Create(studentID, courseID, selectedDate);
                    MessageBox.Show($"Congratulations, You have enrolled successfully\n\n" +
                                    $"Your Booking ID is: {_bookingManager.SelectedBooking.BookingID}");

                    PopulateBookingListBox();
                }
            }
            else
            {
                MessageBox.Show("Please select all the fields to make a booking");
            }
        }
예제 #2
0
        public void WhenAStudentSelectsAnotherBookingForTheSameDateSystemReturnsTrue()
        {
            using (var db = new AcademyContext())
            {
                _bookingManager.Create(2, 5, "01/05/2021");

                bool results  = _bookingManager.DuplicateBookingRecord(2, "01/05/2021");
                bool expected = true;

                Assert.AreEqual(expected, results);
            }
        }