/// <summary> /// Adds the bulk volume. /// </summary> /// <param name="bulkVolume">The bulk volume.</param> /// <returns></returns> public bool AddBulkVolume(UPSEPricingBulkVolume bulkVolume) { string key = this.StringIdentifierForDictionaryReturnOnEmpty(bulkVolume.Data, true); if (!string.IsNullOrEmpty(key)) { if (this.bulkVolumeDictionary == null) { this.bulkVolumeDictionary = new Dictionary <string, UPSEPricingBulkVolume>(); } this.bulkVolumeDictionary[key] = bulkVolume; return(true); } return(false); }
/// <summary> /// Bulks the quantity index for row quantity. /// </summary> /// <param name="row">The row.</param> /// <param name="quantity">The quantity.</param> /// <returns></returns> public int BulkQuantityIndexForRowQuantity(UPSERow row, double quantity) { if (quantity < 0) { string quantityString = row.ValueForFunctionName("Quantity"); if (!string.IsNullOrEmpty(quantityString)) { quantity = Convert.ToDouble(quantityString, System.Globalization.CultureInfo.InvariantCulture); } } UPSEPricingBulkVolume bulkVolume = this.BulkVolumeForRow(row); if (bulkVolume != null) { return(bulkVolume.IndexForQuantity(quantity)); } return(-1); }
/// <summary> /// Searches the operation did finish with result. /// </summary> /// <param name="operation">The operation.</param> /// <param name="result">The result.</param> public void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result) { int count = result.RowCount; Dictionary <string, UPSEPricingBulkVolume> bulkVolumnPerItemNumber = new Dictionary <string, UPSEPricingBulkVolume>(); for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); UPSEPricingBulkVolume volume = new UPSEPricingBulkVolume(row, this); if (volume == null) { continue; } if (!string.IsNullOrEmpty(volume.ItemNumber)) { bulkVolumnPerItemNumber[volume.ItemNumber] = volume; } else { foreach (UPSEPricingBulkVolumeMatch bulkVolumeMatch in this.otherBulkVolumeMatches) { if (bulkVolumeMatch.AddBulkVolume(volume)) { break; } } } } if (bulkVolumnPerItemNumber.Count > 0) { this.bulkVolumePerItemNumber = bulkVolumnPerItemNumber; } this.TheDelegate.PricingBulkVolumesDidFinishWithSuccess(this, this); }
/// <summary> /// Bulks the volume for data. /// </summary> /// <param name="data">The data.</param> /// <returns></returns> public UPSEPricingBulkVolume BulkVolumeForData(Dictionary <string, object> data) { string itemNumber = data.ValueOrDefault(this.ItemNumberFunctionName) as string; if (!string.IsNullOrEmpty(itemNumber)) { UPSEPricingBulkVolume bulkVolume = this.bulkVolumePerItemNumber.ValueOrDefault(itemNumber); if (bulkVolume != null) { return(bulkVolume); } } foreach (UPSEPricingBulkVolumeMatch volumeMatch in this.otherBulkVolumeMatches) { UPSEPricingBulkVolume bulkVolume = volumeMatch.BulkVolumeForDictionary(data); if (bulkVolume != null) { return(bulkVolume); } } return(null); }