/// <summary>
        /// This method will handle updates for a room type
        /// </summary>
        /// <param name="roomTypeChangeMessage">RoomType change message</param>
        public void Handle(RoomTypeChangeMessage roomTypeChangeMessage)
        {
            var businessId = roomTypeChangeMessage.ProviderId.ToLong();
            var roomTypeId = roomTypeChangeMessage.ProductTypeId.ToInt();
            var provider = businessManager.GetBusinessInformationForIntegration(businessId);

            Logger.LogInfo("Message received room Business Id: {0}, room type Id: {1}", null, businessId, roomTypeId);

            //Always handle a delete first
            if (roomTypeChangeMessage.ChangeType == ChangeType.Delete)
            {
                //remove the room type and rate plans from all subscribers
                inventoryUpdate.SendInventoryUpdate(provider.ShortName, roomTypeId);

            }

            //Insert or full update
            if (roomTypeChangeMessage.ChangeType == ChangeType.Insert || roomTypeChangeMessage.IsFullUpdate)
            {
                inventoryUpdate.SendInventoryUpdate(provider.ShortName, roomTypeId);
            }

            //Update
            if (roomTypeChangeMessage.ChangeType == ChangeType.Update)
            {
                if (roomTypeChangeMessage.IsAttributeUpdate)
                {
                    inventoryUpdate.SendInventoryUpdate(provider.ShortName, roomTypeId);
                }
                else if (roomTypeChangeMessage.IsConfigurationUpdate)
                {
                    inventoryUpdate.SendInventoryUpdate(provider.ShortName, roomTypeId);
                }
            }
        }
        /// <summary>
        /// Process Room Type Changes
        /// </summary>
        /// <param name="queueItem">Queue Item</param>
        /// <param name="providerSubscriberOptInLookup">Provider Subscriber Opt In list</param>
        public bool ProcessChange(IQueueItem queueItem, ref ProviderSubscriberOptInsLookup providerSubscriberOptInLookup)
        {
            var roomTypeChange = XmlSerialization.XmlDeserializeFromString<PushRoomTypeUpdate>(queueItem.Payload);
            var providerId = roomTypeChange.BusinessId.ToGuid();
            var roomTypeId = roomTypeChange.RoomTypeId.ToGuid();

            RoomTypeChangeMessage roomTypeChangeMessage;
            RoomTypeChangeType roomTypeChangeType;
            Enum.TryParse(roomTypeChange.Action, out roomTypeChangeType);

            switch (roomTypeChangeType)
            {
                case RoomTypeChangeType.AddRoomType:
                    roomTypeChangeMessage = new RoomTypeChangeMessage(providerId, roomTypeId, ChangeType.Insert, RoomTypeChangeMessage.RoomTypeChangeType.Full);
                    break;
                case RoomTypeChangeType.ModifyRoomType:
                    roomTypeChangeMessage = new RoomTypeChangeMessage(providerId, roomTypeId, ChangeType.Update, RoomTypeChangeMessage.RoomTypeChangeType.Attribute);
                    break;
                case RoomTypeChangeType.DeleteRoomType:
                    roomTypeChangeMessage = new RoomTypeChangeMessage(providerId, roomTypeId, ChangeType.Delete, RoomTypeChangeMessage.RoomTypeChangeType.Full);
                    break;
                default:
                    return false;
            }

            bool isSuccess = true;

            foreach (var messagingIntegratorService in CreateServices(roomTypeChangeMessage))
            {
               isSuccess &= messagingIntegratorService.ProcessAndQueueChangeUpdates(providerSubscriberOptInLookup, roomTypeChangeMessage);
            }

            return isSuccess;
        }
Exemple #3
0
        /// <summary>
        /// This method will handle updates for a room
        /// </summary>
        /// <param name="roomChangeMessage">Room change message</param>
        private void Handle(RoomChangeMessage roomChangeMessage)
        {
            Logger.LogInfo("Message received room Business Id: {0}", null, roomChangeMessage.ProviderId);

            switch (roomChangeMessage.ChangeType)
            {
                //insert, update and delete of rooms should trigger a configuration update for the associated room type
                case ChangeType.Insert:
                case ChangeType.Delete:
                case ChangeType.Update:
                    {
                        var roomTypeChangeMessage = new RoomTypeChangeMessage(roomChangeMessage.ProviderId, roomChangeMessage.ProductTypeId, ChangeType.Update, RoomTypeChangeMessage.RoomTypeChangeType.Configuration);
                        roomTypeMessageHandler.Handle(roomTypeChangeMessage);
                        break;
                    }
            }
        }
Exemple #4
0
        /// <summary>
        /// This method will handle updates for a room type
        /// </summary>
        /// <param name="subscriberByOptinList">List of providers opted into AIG</param>
        /// <param name="roomTypeChangeMessage">RoomType change message</param>
        /// <returns>True is successful otherwise False</returns>
        private bool HandleRoomTypeUpdate(SubscriberByOptinList subscriberByOptinList, RoomTypeChangeMessage roomTypeChangeMessage)
        {
            var businessId = roomTypeChangeMessage.ProviderId.ToLong();
            var roomTypeId = roomTypeChangeMessage.ProductTypeId.ToInt();
            var provider = businessManager.GetBusinessInformationForIntegration(businessId);
            var roomTypesByRatePlan = roomTypeManager.GetAllActiveWithRatePlansForBusinessByRoomTypeId(businessId, roomTypeId, RatePlanTypeEnum.Base);

            //Room Types not found
            if (roomTypesByRatePlan == null || roomTypesByRatePlan.Count == 0)
            {
                return true;
            }

            //Always handle a delete first
            if (roomTypeChangeMessage.ChangeType == ChangeType.Delete)
            {
                //remove the room type and rate plans from all subscribers
                foreach (var subscriberId in subscriberByOptinList.GetSubscribers())
                {
                    if (roomTypesByRatePlan.Select(roomType => CreateRemoveProductMessage(subscriberId, roomTypeChangeMessage.ProviderId, roomType.ProductId)).Any(removeProductMessage => !QueueMessage(removeProductMessage)))
                    {
                        return false;
                    }
                }

                return true;
            }

            //Insert or full update
            if (roomTypeChangeMessage.ChangeType == ChangeType.Insert || roomTypeChangeMessage.IsFullUpdate)
            {                
                foreach (var roomType in roomTypesByRatePlan)
                {
                    var interfaceProduct = ConvertRoomTypeToAigProduct(roomType, provider.CheckinTime, provider.CheckoutTime);

                    interfaceProduct.RatesRestrictionsDateRange = ExtractRateRestrictions(provider.Id, new Guid(roomType.ProductId));
                    CheckPriceRatesExists(interfaceProduct, roomTypeChangeMessage.ProviderId);

                    //create a product add message against all subscribers for room type and rate plans
                    foreach (var subscriberId in subscriberByOptinList.GetSubscribers())
                    {
                        if (!QueueMessage(CreateProductAddRemoveMessage(interfaceProduct, subscriberId, roomTypeChangeMessage.ProviderId)))
                        {
                            return false;
                        }
                    }
                }
                return true;
            }

            //Update
            if (roomTypeChangeMessage.ChangeType == ChangeType.Update)
            {
                if (roomTypeChangeMessage.IsAttributeUpdate)
                {
                    foreach (var roomType in roomTypesByRatePlan)
                    {
                        var interfaceProduct = SetAigProductAttributes(roomType, provider.CheckinTime, provider.CheckoutTime);
                        //create a attribute update against all subscribers for room type and rate plans
                        if (subscriberByOptinList.GetSubscribers().Any(subscriberId => !QueueMessage(CreateProductAttributeChangeMessage(interfaceProduct, subscriberId, roomTypeChangeMessage.ProviderId))))
                        {
                            return false;
                        }
                    }
                }
                else if (roomTypeChangeMessage.IsConfigurationUpdate)
                {
                    foreach (var roomType in roomTypesByRatePlan)
                    {
                        AIGProduct interfaceProduct = null;
                        SetAigProductConfiguration(roomType, ref interfaceProduct);

                        //create a configuration update against all subscribers for room type and rate plans
                        if (subscriberByOptinList.GetSubscribers().Any(subscriberId => !QueueMessage(CreateProductConfigurationChangeMessage(interfaceProduct, subscriberId, roomTypeChangeMessage.ProviderId))))
                        {
                            return false;
                        }
                    }
                }
                return true;
            }

            return true;
        }
Exemple #5
0
 /// <summary>
 /// This method will handle updates for a room
 /// </summary>
 /// <param name="subscriberByOptinList">List of providers opted into AIG</param>
 /// <param name="roomChangeMessage">Room change message</param>
 /// <returns>True is successful otherwise False</returns>
 private bool HandleRoomUpdate(SubscriberByOptinList subscriberByOptinList, RoomChangeMessage roomChangeMessage)
 {
     switch (roomChangeMessage.ChangeType)
     {
         //insert, update and delete of rooms should trigger a configuration update for the associated room type
         case ChangeType.Insert:
         case ChangeType.Delete:
         case ChangeType.Update:
             {
                 var roomTypeChangeMessage = new RoomTypeChangeMessage(roomChangeMessage.ProviderId, roomChangeMessage.ProductTypeId, ChangeType.Update, RoomTypeChangeMessage.RoomTypeChangeType.Configuration);
                 return HandleRoomTypeUpdate(subscriberByOptinList, roomTypeChangeMessage);
             }
     }
     return true;
 }