internal static IEnumerable <ItemAvailability> GetAllItemAvailablitiesByItemQuantities(RequestContext context, string customerId, ICollection <ItemQuantity> itemQuantities, int maxWarehousesPerItem)
            {
                QueryResultSettings queryResultSettings = QueryResultSettings.AllRecords;

                // Get item availabilities.
                var itemQuantitiesRequest = new GetItemAvailabilitiesByItemQuantitiesServiceRequest(
                    queryResultSettings,
                    itemQuantities,
                    customerId,
                    maxWarehousesPerItem);

                var itemQuantitiesResponse = context.Execute <GetItemAvailabilitiesByItemQuantitiesServiceResponse>(itemQuantitiesRequest);

                return(itemQuantitiesResponse.ItemAvailabilities.Results);
            }
            private static GetItemAvailabilitiesByItemQuantitiesServiceResponse GetItemAvailabilitiesByItemQuantities(GetItemAvailabilitiesByItemQuantitiesServiceRequest request)
            {
                var settings = request.QueryResultSettings ?? QueryResultSettings.AllRecords;
                PagedResult <ItemAvailability> itemAvailabilities = null;

                try
                {
                    var searchCriteria = new ItemAvailabilitiesQueryCriteria(request.ItemQuantities, request.CustomerAccountNumber, request.MaxWarehousesPerItem);
                    var dataRequest    = new GetItemAvailabilitiesDataRequest(searchCriteria, settings);
                    itemAvailabilities = request.RequestContext.Execute <EntityDataServiceResponse <ItemAvailability> >(dataRequest).PagedEntityCollection;
                }
                catch (StorageException)
                {
                    // supress exception in order not to block the order
                    // raise the notification instead
                    UnableToDetermineQuantityNotification notification = new UnableToDetermineQuantityNotification(request.ItemQuantities.Select(itemQuantity => itemQuantity.GetItem()));
                    request.RequestContext.Notify(notification);
                }

                return(new GetItemAvailabilitiesByItemQuantitiesServiceResponse(itemAvailabilities));
            }