Esempio n. 1
0
 public ActivityBookingDataContract BookActivityForUser(ActivityBookingDataContract bookingDetails)
 {
     return ExecuteFaultHandledOperation(() =>
     {
         IActivitiesBookingEngine activitiesBookingEngine
           = _BusinessEngineFactory.GetBusinessEngine<IActivitiesBookingEngine>();
         ActivityBooking activityBooking = new ActivityBooking();
         activityBooking.ActivityBookingKey = bookingDetails.ActivityBookingKey;
         activityBooking.BookingNumber = string.Format("{0}{1}", MMC, GetUniqueKey());
         activityBooking.ActivityPricingKey = bookingDetails.ActivityPricingKey;
         activityBooking.ActivityKey = bookingDetails.ActivityKey;
         activityBooking.BookingDate = Convert.ToDateTime(bookingDetails.BookingDate);
         activityBooking.ChildParticipants = bookingDetails.ChildParticipants;
         activityBooking.Participants = bookingDetails.Participants;
         activityBooking.SessionKey = bookingDetails.SessionKey;
         activityBooking.Time = bookingDetails.Time;
         activityBooking.IsConfirmed = bookingDetails.IsConfirmed;
         activityBooking.IsDeleted = bookingDetails.IsDeleted;
         activityBooking.IsCancelled = bookingDetails.IsCancelled;
         activityBooking.PaymentAmount = bookingDetails.PaymentAmount;
         activityBooking.RefundAmount = bookingDetails.RefundAmount;
         activityBooking.IsPaymentComplete = bookingDetails.IsPaymentComplete;
         activityBooking.CreatedDate = bookingDetails.CreatedDate;
         activitiesBookingEngine.BookActivityForUser(activityBooking);
         return bookingDetails;
     });
 }
        public ActivityBooking BookActivityForUser(ActivityBooking bookingDetails)
        {
            IActivitiesMasterRepository activitiesMasterRepository
                   = _DataRepositoryFactory.GetDataRepository<IActivitiesMasterRepository>();

            IActivityBookingRepository activityBookingRepository
                = _DataRepositoryFactory.GetDataRepository<IActivityBookingRepository>();

            ActivitiesMaster activity = activitiesMasterRepository.Get(bookingDetails.ActivityKey);

            IEnumerable<ActivityBooking> allBookedActivites = activityBookingRepository.Get();

            if (bookingDetails.BookingDate < DateTime.Now.Date)
            {
                throw new UnableToRentForDateException(string.Format("Cannot book activity for date {0} yet.", bookingDetails.BookingDate.ToShortDateString()));
            }
            bool isActivityAvailable = IsActivityAvailable(bookingDetails.ActivityKey, bookingDetails.BookingDate, bookingDetails.Time, allBookedActivites,
                bookingDetails.Participants, bookingDetails.ChildParticipants, activity);

            ///TBD ONCE LOGIN IS IMPLEMENTED
            //IAccountRepository accountRepository
            //= _DataRepositoryFactory.GetDataRepository<IAccountRepository>();

            //Account authAccount = accountRepository.ValidateUserByLogin(loginUser);

            //if (authAccount == null)
            //{
            //    throw new NotFoundException(string.Format("No account found for login '{0}'.", loginUser));
            //}

            //Check to support instant booking
            if (activity.AllowInstantBooking != null && Convert.ToBoolean(activity.AllowInstantBooking))
            {
                bookingDetails.IsConfirmed = true;
                bookingDetails.IsPaymentComplete = true;
            }
            ActivityBooking savedActivity = activityBookingRepository.Add(bookingDetails);
            return savedActivity;
        }