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 IEnumerable<ActivityBookingDataContract> GetUsersCurrentActivityCart(string sessionKey, string userAgent)
        {
            return ExecuteFaultHandledOperation(() =>
            {
                IActivitiesBookingEngine activitiesBookingEngine
                    = _BusinessEngineFactory.GetBusinessEngine<IActivitiesBookingEngine>();

                IActivitiesMasterRepository activitiesRepository = _DataRepositoryFactory.GetDataRepository<IActivitiesMasterRepository>();
                IActivityLocationRepository activityLocationRepository = _DataRepositoryFactory.GetDataRepository<IActivityLocationRepository>();
                IEnumerable<ActivityBooking> allBookedActivites = activitiesBookingEngine.GetBookedActivitiesForUser(sessionKey, default(string));
                IActivityImagesRepository imageRepository = _DataRepositoryFactory.GetDataRepository<IActivityImagesRepository>();
                IActivityPriceMappingRepository priceMappingRepository = _DataRepositoryFactory.GetDataRepository<IActivityPriceMappingRepository>();
                ILocationsMasterRepository locationRepository = _DataRepositoryFactory.GetDataRepository<ILocationsMasterRepository>();
                List<ActivityBookingDataContract> result = new List<ActivityBookingDataContract>();
                foreach (var item in allBookedActivites)
                {
                    ActivityBookingDataContract bookedActivities = new ActivityBookingDataContract();
                    bookedActivities.ActivityBookingKey = item.ActivityBookingKey;
                    bookedActivities.ActivityKey = item.ActivityKey;
                    bookedActivities.Currency = activitiesRepository.Get(item.ActivityKey).Currency;
                    bookedActivities.Cost = priceMappingRepository.Get(item.ActivityPricingKey).PriceForAdults;
                    bookedActivities.CostChild = priceMappingRepository.Get(item.ActivityPricingKey).PriceForChildren;
                    bookedActivities.ActivityName = activitiesRepository.Get(item.ActivityKey).Name;
                    bookedActivities.Location = locationRepository.Get(activityLocationRepository.Get().
                        Where(entity => entity.ActivityKey == item.ActivityKey).FirstOrDefault().LocationKey).LocationName.ToLower();
                    bookedActivities.BookingDate = item.BookingDate;
                    bookedActivities.ChildParticipants = item.ChildParticipants;
                    bookedActivities.Participants = item.Participants;
                    bookedActivities.SessionKey = item.SessionKey;
                    bookedActivities.Time = item.Time;
                    bookedActivities.IsConfirmed = item.IsConfirmed;
                    bookedActivities.IsDeleted = item.IsDeleted;
                    bookedActivities.IsCancelled = item.IsCancelled;
                    bookedActivities.PaymentAmount = item.PaymentAmount;
                    bookedActivities.RefundAmount = item.RefundAmount;
                    bookedActivities.IsPaymentComplete = item.IsPaymentComplete;
                    bookedActivities.CreatedDate = Convert.ToDateTime(item.CreatedDate);
                    bookedActivities.ConfirmationDate = Convert.ToDateTime(item.ConfirmationDate);
                    string thumbnailImageURL = imageRepository.Get().Where(entity => entity.ActivityKey == item.ActivityKey
                        && entity.IsThumbnail == true).FirstOrDefault().ImageURL;
                    if (userAgent == BusinessResource.SMARTPHONE)
                    {
                        bookedActivities.ThumbnailImage = string.Format("Images/{0}{1}", thumbnailImageURL, MOBILE);
                    }
                    else if (userAgent == BusinessResource.TABLET)
                    {
                        bookedActivities.ThumbnailImage = string.Format("Images/{0}{1}", thumbnailImageURL, MOBILE);
                    }
                    else
                    {
                        bookedActivities.ThumbnailImage = string.Format("Images/{0}{1}", thumbnailImageURL, MOBILE);
                    }
                    result.Add(bookedActivities);
                }
                return result;
            });
        }
        public IEnumerable<ActivityBookingDataContract> GetAllUpcomingCompanyActivities(string companyKey)
        {
            return ExecuteFaultHandledOperation(() =>
            {
                IActivityBookingRepository activityBookingRepository
                  = _DataRepositoryFactory.GetDataRepository<IActivityBookingRepository>();
                IActivitiesMasterRepository activitiesMasterRepository =
                    _DataRepositoryFactory.GetDataRepository<IActivitiesMasterRepository>();

                IEnumerable<ActivityBooking> allBookings = new List<ActivityBooking>();

                if (companyKey == ALL)
                {
                    allBookings = activityBookingRepository.GetAllUpcomingActivities();
                }
                else
                {
                    allBookings = activityBookingRepository.GetAllUpcomingCompanyActivities(companyKey);
                }
                List<ActivityBookingDataContract> activityBookingList = new List<ActivityBookingDataContract>();
                foreach (var activityBooking in allBookings)
                {
                    ActivityBookingDataContract bookingContract = new ActivityBookingDataContract();
                    ActivitiesMaster activity = activitiesMasterRepository.Get(activityBooking.ActivityKey);
                    bookingContract.ActivityBookingKey = activityBooking.ActivityBookingKey;
                    bookingContract.ActivityKey = activityBooking.ActivityKey;
                    bookingContract.ActivityName = activity.Name;
                    bookingContract.BookingDate = activityBooking.BookingDate;
                    bookingContract.BookingNumber = activityBooking.BookingNumber;
                    bookingContract.ChildParticipants = activityBooking.ChildParticipants;
                    bookingContract.Participants = activityBooking.Participants;
                    bookingContract.PaymentAmount = activityBooking.PaymentAmount;
                    bookingContract.Currency = activity.Currency;
                    bookingContract.Cost = activityBooking.PaymentAmount;
                    bookingContract.Time = activityBooking.Time;
                    activityBookingList.Add(bookingContract);
                }
                return activityBookingList.OrderBy(e => e.BookingDate);
            });
        }