public int PostBooking(Booking booking)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //Call AddBooking method to fetch all Flight
                    int BookingId = bs.AddBooking(booking);

                    //return the response
                    return(BookingId);
                }
                catch (BookingsException)
                {
                    //throw
                    throw;
                }
            }
            else
            {
                //throw user defined exception
                throw new BookingsException("Flight not available for this route, booking can not be done for your requirment");
            }
        }
Exemple #2
0
        public int PostBooking(Booking booking)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //Call AddFlight method to fetch all Flight
                    int BookingId = bs.AddBooking(booking);

                    //return the response
                    return(BookingId);
                }
                catch (FlightException)
                {
                    //rethrow
                    throw;
                }
            }
            else
            {
                //throw user defined exception object
                throw new BookingsException("The entered details are not valid");
            }
        }