/// <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); }
/// <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); }