Example #1
0
        public void SetBooking(Booking booking)
        {
            if (booking == null)
                return;
            
            if (_booking == null || _booking.Id != booking.Id)
            {
                _booking = booking;
                _provisionInfo = _booking.ProvisionInfo;

                RequestCityVehicleInfo();
                RequestSpecialOccasion();

                //waiting time
                if (_provisionInfo.WaitingTime > ApprovedWaitingTimes.Last().Value)
                    _provisionInfo.WaitingTime = 0;
                IsApprovedWaitingTimeYes = _provisionInfo.WaitingTime != 0;
                OnPropertyChanged(() => SelectedApprovedWaitingTime);

                OnPropertyChanged(() => CarryOnBaggage);
                OnPropertyChanged(() => EventName);
            }
            else if (_booking.CityId != booking.CityId || _booking.VehicleTypeId.Value != booking.VehicleTypeId.Value)
            {
                _booking = booking;
                _provisionInfo = _booking.ProvisionInfo;
                RequestCityVehicleInfo();
            }
            else
                _provisionInfo = _booking.ProvisionInfo;

            if (Currency == null || Currency.Id != _booking.FareInfo.Currency.Id)
            {
                Currency = _booking.FareInfo.Currency;
                OnPropertyChanged(() => Currency);
            }
        }
Example #2
0
     public bool Equals(BookingProvisionInfo other)
     {
         if (ReferenceEquals(null, other)) return false;
         if (ReferenceEquals(this, other)) return true;
 		if (other.BookingId == 0 && BookingId == 0)
 			return false;
 		else
 			return other.BookingId == BookingId;
     }
Example #3
0
        public SaveBookingProvisionInfoResponse SaveBookingProvisionInfo(int bookingId, BookingProvisionInfo info)
        {
            try
            {
                using (var db = new LomsContext())
                {
                    db.BookingProvisionInfoes.ApplyChanges(info);

                    db.BookingPaymentItems.Where(p => p.BookingId == bookingId).ForEach(item => db.BookingPaymentItems.DeleteObject(item));

                    //remove charge info and incompleted credit card transactions
                    var chargeInfo = db.BookingChargeInfoes.SingleOrDefault(ci => ci.BookingId == bookingId);
                    if (chargeInfo != null)
                        db.BookingChargeInfoes.DeleteObject(chargeInfo);
                    db.BookingTransactionCreditCards.Where(p => p.BookingId == bookingId && p.OrderDateTime == null).ForEach(item => db.BookingTransactionCreditCards.DeleteObject(item));

                    db.SaveChanges();

                    var response = new SaveBookingProvisionInfoResponse();
                    response.PaymentInfo = db.BookingPayments.IncludeAll("CreditCard", "Items").FirstOrDefault(b => b.BookingId == bookingId);
                    return response;
                }
            }
            catch (Exception ex)
            {
                var response = new SaveBookingProvisionInfoResponse();
                response.AddError("Response", ex.ToString());
                return response;
            }
        }
Example #4
0
     private void FixupProvisionInfo(BookingProvisionInfo previousValue)
     {
         // This is the principal end in an association that performs cascade deletes.
         // Update the event listener to refer to the new dependent.
         if (previousValue != null)
         {
             ChangeTracker.ObjectStateChanging -= previousValue.HandleCascadeDelete;
         }
 
         if (ProvisionInfo != null)
         {
             ChangeTracker.ObjectStateChanging += ProvisionInfo.HandleCascadeDelete;
         }
 
         if (IsDeserializing)
         {
             return;
         }
 
         if (ProvisionInfo != null)
         {
             ProvisionInfo.BookingId = Id;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("ProvisionInfo")
                 && (ChangeTracker.OriginalValues["ProvisionInfo"] == ProvisionInfo))
             {
                 ChangeTracker.OriginalValues.Remove("ProvisionInfo");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("ProvisionInfo", previousValue);
                 // This is the principal end of an identifying association, so the dependent must be deleted when the relationship is removed.
                 // If the current state of the dependent is Added, the relationship can be changed without causing the dependent to be deleted.
                 if (previousValue != null && previousValue.ChangeTracker.State != ObjectState.Added)
                 {
                     previousValue.MarkAsDeleted();
                 }
             }
             if (ProvisionInfo != null && !ProvisionInfo.ChangeTracker.ChangeTrackingEnabled)
             {
                 ProvisionInfo.StartTracking();
             }
         }
     }