Exemplo n.º 1
0
        /// <param name="c">Customer</param>
        /// <param name="flights">array of flight names</param>
        /// <param name="location">room location if room is true</param>
        /// <param name="car">true if request is for a car</param>
        /// <param name="room">true if request is for a room</param>
        /// <returns>price of reservation</returns>
        public bool ReserveItinerary(TP.Customer c, string[] flights, string location, bool car, bool room)
        {
            TP.Transaction tid = TransactionManager.Start();

            try
            {
                if (car)
                {
                    Cars.Reserve(tid, c, RID.forCar(location));
                }

                if (room)
                {
                    Rooms.Reserve(tid, c, RID.forRoom(location));
                }

                foreach (string flight in flights)
                {
                    Flights.Reserve(tid, c, RID.forFlight(flight));
                }

                TransactionManager.Commit(tid);
            }
            catch (Exception e)
            {
                TransactionManager.Abort(tid);
                throw;
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <param name="c">Customer</param>
        /// <param name="flights">array of flight names</param>
        /// <param name="location">room location if room is true</param>
        /// <param name="car">true if request is for a car</param>
        /// <param name="room">true if request is for a room</param>
        /// <returns>price of reservation</returns>
        public bool ReserveItinerary(TP.Customer c, string[] flights, string location, bool car, bool room)
        {
            TP.Transaction tid = TransactionManager.Start();

            try
            {
                if (car)
                {
                    bool result = Cars.Reserve(tid, c, RID.forCar(location));
                    if (!result)
                    {
                        throw new InvalidOperationException();
                    }
                }

                if (room)
                {
                    bool result = Rooms.Reserve(tid, c, RID.forRoom(location));
                    if (!result)
                    {
                        throw new InvalidOperationException();
                    }
                }

                foreach (string flight in flights)
                {
                    bool result = Flights.Reserve(tid, c, RID.forFlight(flight));
                    if (!result)
                    {
                        throw new InvalidOperationException();
                    }
                }

                Commit(tid);
            }
            catch (AbortTransationException)
            {
                Abort(tid);
                return(false);
            }
            catch (ArgumentException)
            {
                Abort(tid);
                return(false);
            }
            catch (DeadLockDetected)
            {
                Abort(tid);
                return(false);
            }
            catch (InvalidOperationException)
            {
                Abort(tid);
                return(false);
            }
            catch (Exception e)
            {
                Abort(tid);
                throw e;
            }

            return(true);
        }
Exemplo n.º 3
0
 public int QueryFlightPrice(Transaction context, String flight)
 {
     return(Flights.QueryPrice(context, RID.forFlight(flight)));
 }
Exemplo n.º 4
0
 public bool DeleteFlight(Transaction context, string flight)
 {
     return(Flights.Delete(context, RID.forFlight(flight)));
 }
Exemplo n.º 5
0
 public bool DeleteSeats(Transaction context, String flight, int numSeats)
 {
     return(Flights.Delete(context, RID.forFlight(flight), numSeats));
 }
Exemplo n.º 6
0
 /*************** Client interface methods **************************/
 public bool AddSeats(Transaction context, String flight, int flightSeats,
                      int flightPrice)
 {
     return(Flights.Add(context, RID.forFlight(flight), flightSeats, flightPrice));
 }