Пример #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);
        }
Пример #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);
        }
Пример #3
0
 public int QueryRoomPrice(Transaction context, String location)
 {
     return(Rooms.QueryPrice(context, RID.forRoom(location)));
 }
Пример #4
0
 public bool DeleteRooms(Transaction context, String location, int numRooms)
 {
     return(Rooms.Delete(context, RID.forRoom(location), numRooms));
 }
Пример #5
0
 public bool AddRooms(Transaction context, String location, int numRooms,
                      int price)
 {
     return(Rooms.Add(context, RID.forRoom(location), numRooms, price));
 }