Exemplo n.º 1
0
        /// <summary>
        /// This method will call the base handler methods depending on the type of availbility update item.
        /// </summary>
        /// <param name="providerAndSubscriberOptInLookup">List of providers opted into AIG</param>
        /// <param name="baseChangeMessage">Availability update item to process</param>
        /// <returns>True is successful otherwise False</returns>
        private bool HandleChangeMessage(ProviderSubscriberOptInsLookup providerAndSubscriberOptInLookup, BaseChangeMessage baseChangeMessage)
        {
            //get the AIGSubscriberByOptinPriceTypeList list now or null. it could be null in a case
            //where it is a provider opt out and the list has been refreshed.
            var subscriberByOptinList = (providerAndSubscriberOptInLookup == null) ? null : providerAndSubscriberOptInLookup.GetSubscribersByProviderId(baseChangeMessage.ProviderId);

            if (subscriberByOptinList == null)
            {
                return true;
            }

            try
            {
                var inventoryChangeMessage = baseChangeMessage as InventoryChangeMessage;
                if (inventoryChangeMessage != null)
                {
                    return HandleInventoryUpdate(subscriberByOptinList, inventoryChangeMessage);
                }

                var providerChangeMessage = baseChangeMessage as ProviderChangeMessage;
                if (providerChangeMessage != null)
                {
                    return HandleProviderUpdate(subscriberByOptinList, providerChangeMessage);
                }

                var ratePlanChangeMessage = baseChangeMessage as RatePlanChangeMessage;
                if (ratePlanChangeMessage != null)
                {
                    return HandleRatePlanUpdate(subscriberByOptinList, ratePlanChangeMessage);
                }

                var roomTypeChangeMessage = baseChangeMessage as RoomTypeChangeMessage;
                if (roomTypeChangeMessage != null)
                {
                    return HandleRoomTypeUpdate(subscriberByOptinList, roomTypeChangeMessage);
                }

                var roomChangeMessage = baseChangeMessage as RoomChangeMessage;
                if (roomChangeMessage != null)
                {
                    return HandleRoomUpdate(subscriberByOptinList, roomChangeMessage);
                }

                return true;
            }
            catch (Exception ex)
            {
                //this is a catch all if anything goes wrong during the data retrieval part
                Logger.ErrorFormat("Error occured while processing {0} {1}", baseChangeMessage, ex);

                var providerErrorMessage = ProviderError.CreateProviderError(baseChangeMessage.SubscriberId.ToString(), baseChangeMessage.ProviderId.ToString(), "Unhandled exception during procesing: " + ex.Message);

                return QueueMessage(providerErrorMessage);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method will check to confirm that an update is required for this change message
        /// </summary>
        /// <param name="providerAndSubscriberOptInLookup">List of providers opted in to AIG</param>
        /// <param name="baseChangeMessage">Base change message to check</param>
        /// <returns>True if successful otherwise False</returns>
        private static bool IsChangeMessageRequiredUpdate(ProviderSubscriberOptInsLookup providerAndSubscriberOptInLookup, BaseChangeMessage baseChangeMessage)
        {
            if (providerAndSubscriberOptInLookup.ContainsProvider(baseChangeMessage.ProviderId))
            {
                var subscriberByOptinList = providerAndSubscriberOptInLookup.GetSubscribersByProviderId(baseChangeMessage.ProviderId);

                if (subscriberByOptinList == null)
                {
                    return false;
                }
                    
                //updates involving a businessaccount being activated/deactivated will not contain a distributor id
                if (baseChangeMessage.SubscriberId == Guid.Empty)
                {
                    return true;
                }

                if (subscriberByOptinList.ContainsSubscriber(baseChangeMessage.SubscriberId))
                {
                    return true;
                }
            }

            return false;
        }