Exemplo n.º 1
0
        /// <summary>
        /// Make an order for the client.
        /// </summary>
        /// <param name="request">The reservation request</param>
        /// <returns>reservation ID</returns>
        public int MakeReservation(FlightSearchReservationRequest request)
        {
            // Search for the flight
            foreach (Flight flight in flights)
            {
                if (flight.flightNumber.Equals(request.flightNumber) && flight.date.Equals(request.date))
                {
                    // if there is no place in the plane - error!
                    if (flight.seats == 0)
                    {
                        throw new Exception("no seats available");
                    }

                    // Reduce seats
                    flight.seats--;

                    // Build a reservation
                    TicketSearchReservation reservation = new TicketSearchReservation();
                    reservation.flightNumber  = request.flightNumber;
                    reservation.date          = request.date;
                    reservation.reservationID = ++reservationIdCreator;
                    reservations.Add(reservation);
                    return(reservation.reservationID);
                }
            }
            throw new Exception("no such flight");
        }
Exemplo n.º 2
0
        public int MakeReservation(FlightSearchReservationRequest request)
        {
            int resID;

            try
            {
                resID = TicketSellingQueryLogic.Instance.MakeReservation(request);
            }
            catch (Exception e)
            {
                throw new FaultException(e.Message);
            }
            return(resID);
        }