/// <summary> /// Fetches the delivery options applicable for the item/inventDimId and Address. /// </summary> /// <param name="request">The request.</param> /// <returns>Delivery options applicable.</returns> /// <remarks>This API is typically used to display the delivery options in Item details page.</remarks> private static GetProductDeliveryOptionsServiceResponse GetProductDeliveryOptions(GetProductDeliveryOptionsServiceRequest request) { if (request.ShippingAddress == null) { throw new ArgumentNullException("request", "request.ShippingAddress"); } var dataServiceRequest = new GetItemDeliveryOptionsDataRequest(request.ItemId, request.InventoryDimensionId, request.ShippingAddress.ThreeLetterISORegionName, request.ShippingAddress.State); dataServiceRequest.QueryResultSettings = request.QueryResultSettings; var dataServiceResponse = request.RequestContext.Execute <EntityDataServiceResponse <DeliveryOption> >(dataServiceRequest); var deliveryOptions = dataServiceResponse.PagedEntityCollection; // Raise notification if no delivery options are found. if (!deliveryOptions.Results.Any()) { EmptyProductDeliveryOptionSetNotification notification = new EmptyProductDeliveryOptionSetNotification(request.ShippingAddress, request.ItemId, request.InventoryDimensionId); request.RequestContext.Notify(notification); } return(new GetProductDeliveryOptionsServiceResponse(deliveryOptions)); }
private static void NotifyEmptyProductDeliveryOptionSetNotification(EmptyProductDeliveryOptionSetNotification notification) { throw new ConfigurationException( ConfigurationErrors.Microsoft_Dynamics_Commerce_Runtime_UnableToFindDeliveryOptions, string.Format("No delivery option found for the the product. Ensure the required job is run properly. ItemId: {0}, InventoryDimensionId: {1}, Address: {2}", notification.ItemId, notification.InventoryDimensionId, notification.Address)); }