Пример #1
0
        /// <summary>
        /// Method to delete a route
        /// </summary>
        /// <param name="checkpointID"></param>
        /// <returns></returns>
        public bool DeleteRoute(string routeId)
        {
            bool isBookingsDeleted = false;

            List <Booking> routeBookings = bookingDataAccess.GetAllBookingsByRouteID(routeId);

            if (routeBookings.Count == 0)
            {
                isBookingsDeleted = true;
            }

            foreach (Booking booking in routeBookings)
            {
                isBookingsDeleted = bookingDataAccess.DeleteBooking(booking.Booking_ID);
            }

            return(isBookingsDeleted && routeDataAccess.DeleteRoute(routeId));
        }
Пример #2
0
        /// <summary>
        /// Method to cancel a booking
        /// </summary>
        /// <param name="booking"></param>
        /// <returns></returns>
        public bool DeleteBooking(string bookingID)
        {
            Booking  booking        = GetBooking(bookingID);
            DateTime localDate      = DateTime.Now;
            TimeSpan timeDifference = localDate - booking.Booking_Route.Route_Journey.Departure_Time;


            if (true)
            {
                Route bookingRoute     = booking.Booking_Route;
                int   newNumberOfSeats = bookingRoute.Available_Seats + 1;

                //Deletes the booking and increments the number of seats available for the route
                return(bookingDataAccess.DeleteBooking(booking.Booking_ID) && routeDataAccess.UpdateRouteSeats(bookingRoute.Route_ID, newNumberOfSeats));
            }
            else
            {
                return(false);
            }
        }