Beispiel #1
0
        public void GetReservationsTest()
        {
            ReservationSqlDAL dal = new ReservationSqlDAL(ConnectionString);

            var reservations = dal.GetReservations(1, 1, 1);

            Assert.AreEqual(1, reservations.Count);
        }
Beispiel #2
0
        /// <summary>
        /// Checks the entered requested date range against existing reservations for that selected site at the selected campground at the selected park
        /// </summary>
        /// <param name="parkId"></param>
        /// <param name="campgroundId"></param>
        /// <param name="siteNumber"></param>
        /// <param name="desiredReservationDates"></param>
        /// <returns>Reservation at the selected site at the selected campground at the selected park</returns>
        private Reservation CheckAvailableReservation(int parkId, int campgroundId, int siteId, int siteNumber, DateTime[] desiredReservationDates)
        {
            ReservationSqlDAL   dal                   = new ReservationSqlDAL(DatabaseConnection);
            IList <Reservation> reservations          = dal.GetReservations(parkId, campgroundId, siteNumber);
            Reservation         successfulReservation = new Reservation();
            bool isValidReservation                   = true;

            foreach (var reservation in reservations)
            {
                if ((desiredReservationDates[0] >= reservation.StartDate && desiredReservationDates[0] <= reservation.EndDate) || (desiredReservationDates[1] >= reservation.StartDate && desiredReservationDates[1] <= reservation.EndDate))
                {
                    isValidReservation = false;
                    Console.WriteLine("Reservation already booked during all or part of this date range. Please select another date range.");
                    break;
                }
            }
            if (isValidReservation)
            {
                Console.Write("Please Enter Reservation Name: ");
                string reservationName = Console.ReadLine();
                successfulReservation = dal.AddReservation(siteId, reservationName, desiredReservationDates);
            }
            return(successfulReservation);
        }