Exemple #1
0
        /// <summary>
        /// Get all Room Types for a Provider and Convert to AIG product
        /// </summary>
        /// <param name="providerId">Provider Id</param>        
        /// <param name="checkinTime">Checkin Time</param>
        /// <param name="checkoutTime">Checkout Time</param>
        /// <returns>Array of AIGProduct</returns>
        private AIGProduct[] ExtractAndConvertRoomTypesByProvider(Guid providerId, string checkinTime, string checkoutTime)
        {
            var roomTypes = roomTypeManager.GetAllActiveWithRatePlansForBusiness(providerId.ToLong(), RatePlanTypeEnum.Base);

            if (roomTypes != null && roomTypes.Count != default(int))
            {
                return roomTypes.Select(roomType => ConvertRoomTypeToAigProduct(roomType, checkinTime, checkoutTime)).ToArray();
            }

            Logger.InfoFormat("No rooms found for business {0}", providerId);
            return new AIGProduct[0];            
        }
Exemple #2
0
        /// <summary>
        /// Get all Room Types for a Provider
        /// </summary>
        /// <param name="providerId">Provider Id</param>        
        /// <param name="checkinTime">Checkin Time</param>
        /// <param name="checkoutTime">Checkout Time</param>
        /// <returns>Array of AIGProduct</returns>
        private AIGProduct[] ExtractRoomTypesByProvider(Guid providerId, string checkinTime, string checkoutTime)
        {
            var extractedAigProductsByProviderId = ExtractAndConvertRoomTypesByProvider(providerId, checkinTime, checkoutTime);
            var interfaceProductsWithPricingList = new List<AIGProduct>();

            //only handling Serviced Accommodation at the moment
            foreach (var interfaceProduct in extractedAigProductsByProviderId)
            {
                interfaceProduct.RatesRestrictionsDateRange = ExtractRateRestrictions(providerId.ToLong(), new Guid(interfaceProduct.ProductTypeId));
                CheckPriceRatesExists(interfaceProduct, providerId);
                interfaceProductsWithPricingList.Add(interfaceProduct);
            }

            return interfaceProductsWithPricingList.ToArray();
        }
Exemple #3
0
        /// <summary>
        /// This method create a ProviderAvailabilityReset object
        /// </summary>
        /// <param name="subscriberId">Subscriber Id</param>
        /// <param name="providerId">Provider Id</param>        
        /// <returns>ProviderAvailabilityReset object</returns>
        private ProviderAvailabilityReset CreateProviderAvailabilityResetMessage(Guid subscriberId, Guid providerId)
        {
            var provider = businessManager.GetBusinessInformationForIntegration(providerId.ToLong());

            var interfaceProductsList = ExtractRoomTypesByProvider(providerId, provider.CheckinTime, provider.CheckoutTime);

            try
            {
                return
                    ProviderAvailabilityReset.CreateProviderAvailabilityResetMessage(subscriberId.ToString(), providerId.ToString(), interfaceProductsList);
            }
            catch (Exception ex)
            {
                Logger.Error(string.Format("Unable to create ProviderAvailabilityReset message for business {0}, opted into distribution channel {1}", providerId, subscriberId), ex);
            }
            return null;
        }
Exemple #4
0
        /// <summary>
        /// This method create a ProviderDistributionChange object
        /// </summary>
        /// <param name="subscriberId">Subscriber Id</param>
        /// <param name="providerId">Provider Id</param>        
        /// <param name="changeType">Type of change</param>
        /// <returns>ProductAvailabilityChange object</returns>
        private ProviderDistributionChange CreateProviderDistributionChangeMessage(Guid subscriberId, Guid providerId, ChangeType changeType)
        {
            switch (changeType)
            {
                case ChangeType.Insert:
                case ChangeType.Update:
                {
                    var businessId = providerId.ToLong();
                    var provider = businessManager.GetBusinessInformationForIntegration(businessId);
                    var providerDetail = businessManager.GetProviderInformation(businessId);
                    var distributor = distributorChannelDao.GetDistributorChannelInformation(subscriberId);

                    var interfaceProductsList = ExtractRoomTypesByProvider(providerId, provider.CheckinTime, provider.CheckoutTime);    //Need to add subscriberId (channelId) when rates etc are by channel

                    try
                    {
                        return ProviderDistributionChange.CreateProviderAddedDistributorMessage(
                            distributor.Id.ToString(),
                            distributor.ShortName,
                            supplyPartnerId.ToString(),
                            supplyPartnerShortName,
                            provider.Id.ToGuid().ToString(),
                            providerDetail.ContentId,
                            provider.ShortName,
                            provider.Id.ToString(CultureInfo.InvariantCulture),
                            provider.Name,
                            string.Empty,   //ConditionsOfUse??
                            interfaceProductsList);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(string.Format("Unable to create ProviderDistributionChange.CreateProviderAddedDistributorMessage message for business {0}, opted into distribution channel {1}", provider.ShortName, distributor.ShortName), ex);
                    }
                    break;
                }                    
                case ChangeType.Delete:
                    try
                    {
                        return ProviderDistributionChange.CreateProviderRemovedDistributorMessage(providerId.ToString());
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(string.Format("Unable to create ProviderDistributionChange.CreateProviderRemovedDistributorMessage message for business {0}, opted into distribution channel {1}", providerId, subscriberId), ex);
                    }
                    break;
            }

            Logger.Warn(string.Format("No ProviderDistributionChange message will be sent for business {0}, opted into distribution channel {1} as there is no rooms set up that are bookable online", providerId, subscriberId));

            return null;
        }
Exemple #5
0
        private ProviderReset CreateProviderResetMessage(Guid subscriberId, Guid providerId)
        {
            var businessId = providerId.ToLong();
            var provider = businessManager.GetBusinessInformationForIntegration(businessId);
            var providerDetail = businessManager.GetProviderInformation(businessId);
            var distributor = distributorChannelDao.GetDistributorChannelInformation(subscriberId);

            var interfaceProductsList = ExtractRoomTypesByProvider(providerId, provider.CheckinTime, provider.CheckoutTime);    //Need to add subscriberId (channelId) when rates etc are by channel

            try
            {
                return ProviderReset.CreateProviderResetMessage(
                    distributor.Id.ToString(),
                    distributor.ShortName,
                    supplyPartnerId.ToString(),
                    supplyPartnerShortName,
                    provider.Id.ToGuid().ToString(),
                    providerDetail.ContentId,
                    provider.ShortName,
                    provider.Id.ToString(CultureInfo.InvariantCulture),
                    provider.Name,
                    string.Empty,   //ConditionsOfUse??
                    interfaceProductsList);
            }
            catch (Exception ex)
            {
                Logger.Error(string.Format("Unable to create ProviderReset message for business {0}, opted into distribution channel {1}", providerId, subscriberId), ex);
            }

            return null;
        }