Ejemplo n.º 1
0
        /// <summary>
        /// This method will handle updates for a provider
        /// </summary>
        /// <param name="providerChangeMessage">Provider change message</param>
        public void Handle(ProviderChangeMessage providerChangeMessage)
        {
            Logger.LogInfo("Message received room Business Id : {0}", null, providerChangeMessage.ProviderId.ToLong());

            var businessId = providerChangeMessage.ProviderId.ToLong();
            var provider = businessManager.GetBusinessInformationForIntegration(businessId);

            switch (providerChangeMessage.ChangeType)
            {
                case ChangeType.Insert:
                    {
                        if (providerChangeMessage.IsAvailabilityReset)
                        {
                            inventoryUpdate.SendInventoryUpdate(businessId, provider.ShortName);
                        }
                        else if (providerChangeMessage.IsProviderReset)
                        {

                            restrictionUpdate.SendRatesRestrictionUpdate(businessId, provider.ShortName);
                            rateAmountUpdate.SendRateAmountUpdate(businessId, provider.ShortName);
                            inventoryUpdate.SendInventoryUpdate(businessId, provider.ShortName);
                        }
                        else
                        {
                            restrictionUpdate.SendRatesRestrictionUpdate(businessId, provider.ShortName);
                            rateAmountUpdate.SendRateAmountUpdate(businessId, provider.ShortName);
                            inventoryUpdate.SendInventoryUpdate(businessId, provider.ShortName);
                        }
                        break;
                    }
                case ChangeType.Update: //not sure if we will have these updates in Eagle yet
                    break;
                case ChangeType.Delete:
                    {
                        restrictionUpdate.SendRatesRestrictionClose(businessId, provider.ShortName);
                        inventoryUpdate.SendInventoryClose(businessId, provider.ShortName);
                        break;
                    }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method will handle updates for a provider
        /// </summary>
        /// <param name="subscriberByOptinList">List of providers opted into AIG</param>
        /// <param name="providerChangeMessage">Provider change message</param>
        /// <returns>True is successful otherwise False</returns>
        private bool HandleProviderUpdate(SubscriberByOptinList subscriberByOptinList, ProviderChangeMessage providerChangeMessage)
        {
            object providerDistributionMessage;

            switch (providerChangeMessage.ChangeType)
            {
                case ChangeType.Insert:
                    if (providerChangeMessage.SubscriberId == Guid.Empty)
                    {
                        foreach (var subscriberId in subscriberByOptinList.GetSubscribers())
                        {
                            providerDistributionMessage = CreateProviderDistributionChangeMessage(subscriberId, providerChangeMessage.ProviderId, ChangeType.Insert);

                            return providerDistributionMessage != null && QueueMessage(providerDistributionMessage);
                        }
                    }
                    else
                    {
                        if (providerChangeMessage.IsAvailabilityReset)
                        {
                            providerDistributionMessage = CreateProviderAvailabilityResetMessage(providerChangeMessage.SubscriberId, providerChangeMessage.ProviderId);
                        }
                        else if (providerChangeMessage.IsProviderReset)
                        {
                            providerDistributionMessage = CreateProviderResetMessage(providerChangeMessage.SubscriberId, providerChangeMessage.ProviderId);
                        }
                        else
                        {
                            providerDistributionMessage = CreateProviderDistributionChangeMessage(providerChangeMessage.SubscriberId, providerChangeMessage.ProviderId, ChangeType.Insert);                            
                        }                        

                        return providerDistributionMessage != null && QueueMessage(providerDistributionMessage);
                    }
                    break;
                case ChangeType.Update:     // The providerChangeMessage.SubscriberId will always be empty so send a message for all subscribers
                    foreach (var subscriberId in subscriberByOptinList.GetSubscribers())
                    {
                        providerDistributionMessage = CreateProviderDistributionChangeMessage(subscriberId, providerChangeMessage.ProviderId, ChangeType.Update);

                        return providerDistributionMessage != null && QueueMessage(providerDistributionMessage);
                    }
                    break;
                case ChangeType.Delete:
                    providerDistributionMessage = CreateProviderDistributionChangeMessage(providerChangeMessage.SubscriberId, providerChangeMessage.ProviderId, ChangeType.Delete);

                    return providerDistributionMessage != null && QueueMessage(providerDistributionMessage);
            }
            return true;
        }