/// <summary>
        /// Handle an inventory message
        /// </summary>
        /// <param name="inventoryChangeMessage">InventoryChangeMessage</param>
        /// <returns>True if message has been well processed</returns>
        private void Handle(InventoryChangeMessage inventoryChangeMessage)
        {
            Logger.LogInfo("Message received room RoomTypeId : {0}, Business Id : {1}", null, inventoryChangeMessage.RoomTypeId, inventoryChangeMessage.ProviderId.ToLong());

            var businessId = inventoryChangeMessage.ProviderId.ToLong();

            var business = businessManager.GetBusiness(businessId);

            inventoryUpdate.SendInventoryUpdate(business.ShortName,
                    new int[] { inventoryChangeMessage.RoomTypeId },
                   inventoryChangeMessage.StartDate,
                   inventoryChangeMessage.EndDate);
        }
Beispiel #2
0
        /// <summary>
        /// This method create a ProductAvailabilityChange object
        /// </summary>
        /// <param name="subscriberId">Subscriber Id</param>
        /// <param name="inventoryChangeMessage">Booking change message</param>        
        /// <param name="changeType">Type of change</param>
        /// <returns>ProductAvailabilityChange object</returns>
        private static ProductAvailabilityChange CreateProductAvailabilityChangeMessage(Guid subscriberId, InventoryChangeMessage inventoryChangeMessage, ChangeType changeType)
        {
            switch (changeType)
            {
                case ChangeType.Delete:
                {
                    try
                    {
                        return ProductAvailabilityChange.CreateRoomBookingCancellationMessage(subscriberId.ToString(),
                                                                                              inventoryChangeMessage.ProviderId.ToString(),
                                                                                              inventoryChangeMessage.RoomId.ToString(),
                                                                                              inventoryChangeMessage.StartDate,
                                                                                              inventoryChangeMessage.EndDate);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(string.Format("Unable to create ProductAvailabilityChange CreateRoomBookingCancellationMessage message for business {0}, opted into distribution channel {1} with booking on room {2} for start date {3} and end date {4}", inventoryChangeMessage.ProviderId, inventoryChangeMessage.SubscriberId, inventoryChangeMessage.RoomId, inventoryChangeMessage.StartDate, inventoryChangeMessage.EndDate), ex);
                    }
                    break;                    
                }
                case ChangeType.Insert:
                {
                    try
                    {
                        return ProductAvailabilityChange.CreateRoomBookingMessage(subscriberId.ToString(),
                                                                                  inventoryChangeMessage.ProviderId.ToString(),
                                                                                  inventoryChangeMessage.RoomId.ToString(),
                                                                                  inventoryChangeMessage.StartDate,
                                                                                  inventoryChangeMessage.EndDate);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(string.Format("Unable to create ProductAvailabilityChange CreateRoomBookingMessage message for business {0}, opted into distribution channel {1} with booking on room {2} for start date {3} and end date {4}", inventoryChangeMessage.ProviderId, inventoryChangeMessage.SubscriberId, inventoryChangeMessage.RoomId, inventoryChangeMessage.StartDate, inventoryChangeMessage.EndDate), ex);

                    }
                    break;
                }
            }

            return null;
        }
Beispiel #3
0
        /// <summary>
        /// This method will call the queue handler
        /// </summary>
        /// <param name="subscriberByOptinList">Subscriber by optin price type list</param>
        /// <param name="inventoryChangeMessage">Booking update item to process</param>
        /// <returns>True is successful otherwise False</returns>
        private bool HandleInventoryUpdate(SubscriberByOptinList subscriberByOptinList, InventoryChangeMessage inventoryChangeMessage)
        {
            foreach (var subscriberId in subscriberByOptinList.GetSubscribers())
            {
                return
                    QueueMessage(CreateProductAvailabilityChangeMessage(subscriberId, inventoryChangeMessage,
                                                                        inventoryChangeMessage.ChangeType));
            }

            return true;
        }