public bool ApplyFilter(IFilterRow row) { bool result = false; if (row != null) { String sku = row.GetColumn(Sku).Value; String weightAsString = row.GetColumn(Weight).Value; String volumeAsString = row.GetColumn(Volume).Value; if (String.IsNullOrWhiteSpace(weightAsString) == false && String.IsNullOrWhiteSpace(volumeAsString) == false) { if (decimal.TryParse(weightAsString, out decimal weightAsLBS) && decimal.TryParse(volumeAsString, out decimal volumeAsCubicFeet)) { decimal gramConversionFactor = (decimal)453.59237; decimal weight = gramConversionFactor * weightAsLBS; WeightCubicVolumeInformation wi = new WeightCubicVolumeInformation(weight, weightAsLBS, volumeAsCubicFeet); MatchingRowIds.Add(sku, wi); result = true; } } } return(result); }
public bool ApplyFilter(IFilterRow row) { bool result = false; if (row != null) { row.Handle = row.GetColumn(VariantSku); MatchingRowIds.Add(row.Handle.Value); result = true; } return(result); }
public bool ApplyFilter(IFilterRow row) { bool result = false; IFilterValue weightString = row.GetColumn(Weight); IFilterValue lengthString = row.GetColumn(Length); IFilterValue widthString = row.GetColumn(Width); IFilterValue heightString = row.GetColumn(Height); IFilterValue handle = row.GetColumn("Handle"); bool we = decimal.TryParse(weightString?.Value, out decimal weight); bool le = decimal.TryParse(lengthString?.Value, out decimal length); bool wi = decimal.TryParse(widthString?.Value, out decimal width); bool he = decimal.TryParse(heightString?.Value, out decimal height); if (le && wi && he) { decimal cubicVolumeLength = Math.Round(length); decimal cubicVolumeWidth = Math.Round(width); decimal cubicVolumeHeight = Math.Round(height); decimal dimWeight = cubicVolumeLength * cubicVolumeWidth * cubicVolumeHeight / DimWeightDivisor; if (dimWeight > weight) { weight = dimWeight; } } if (we) { result = (weight < 1); if (result) { row.Handle = handle; row.UnderOnePound = true; MatchingRowIds.Add(handle.Value); } else { row.Handle = handle; row.OverOnePound = true; Console.WriteLine($"Product with Handle={handle?.Value} and weight={weight} exceeds threshold=0.23"); } } return(result); }
public bool ApplyFilter(IFilterRow row) { bool result = false; IFilterValue inventoryString = row.GetColumn(Inventory); IFilterValue handle = row.Handle ?? row.GetColumn("Handle"); if (handle == null || inventoryString == null) { return(result); } int inventory = -1; bool i = int.TryParse(inventoryString.Value, out inventory); if (i && String.IsNullOrEmpty(handle.Value) == false) { if (MinimumInventoryThreshold > 0 && MaximumInventoryThreshold > MinimumInventoryThreshold) { result = inventory >= MinimumInventoryThreshold && inventory <= MaximumInventoryThreshold; } else if (MinimumInventoryThreshold == MaximumInventoryThreshold) { result = inventory > MinimumInventoryThreshold; } if (result) { row.Handle = handle; MatchingRowIds.Add(handle.Value); } else { row.Handle = handle; Console.WriteLine($"Product with Handle={handle} and no inventory."); } } return(result); }
public bool ApplyFilter(IFilterRow row) { bool result = false; if (row != null) { String volumeAsString = row.GetColumn("cubic_volume (in.)").Value; String weightAsString = row.GetColumn(Weight).Value; String priceAsString = row.GetColumn(Price).Value; String msrpAsString = row.GetColumn(Msrp).Value; String mapAsString = row.GetColumn(Map).Value; String sku = row.GetColumn(Sku).Value; WeightCubicVolumeInformation wi = null; decimal.TryParse(msrpAsString, out decimal msrp); decimal.TryParse(weightAsString, out decimal weight); decimal.TryParse(volumeAsString, out decimal volume); decimal.TryParse(mapAsString, out decimal map); if (String.IsNullOrWhiteSpace(weightAsString) == false && String.IsNullOrWhiteSpace(volumeAsString) == false) { if (decimal.TryParse(weightAsString, out decimal weightAsLBS) && decimal.TryParse(volumeAsString, out decimal volumeAsCubicFeet)) { decimal gramConversionFactor = (decimal)453.59237; weight = gramConversionFactor * weightAsLBS; wi = new WeightCubicVolumeInformation(weight, weightAsLBS, volumeAsCubicFeet); } } decimal.TryParse(priceAsString, out decimal price); decimal costPerItem = price; price = (price * (decimal)ProfitMargin); if (price > (decimal)3.0) { price = (Math.Floor(price) + (decimal)0.47); } if (price < costPerItem) { price = (costPerItem * (decimal)ProfitMargin); } if (String.IsNullOrWhiteSpace(mapAsString) == false) { if (price < map) { price = Math.Floor(map) + (decimal)0.49; } } if (msrp > 0) { if (price > msrp) { price = msrp; } } else { msrp = price + (price * (decimal)0.20); } IFilterValue storage = row.GetColumn("storage"); if (storage != null && string.IsNullOrWhiteSpace(storage.Value) == false && (storage.Value == Refrigerated || storage.Value == Frozen)) { price += (decimal)ShippingSurcharge; } decimal volumeShippingCost = 0; decimal weightShippingCost = 0; if (wi != null && ShouldAddShipping) { (volumeShippingCost, weightShippingCost) = ShippingCost.Get(wi); if (volumeShippingCost < weightShippingCost) { price += weightShippingCost; } else { price += volumeShippingCost; } } PriceInformation pi = new PriceInformation(msrp.ToString("C2"), msrp.ToString("C2"), costPerItem.ToString("C2"), price.ToString("C2")); MatchingRowIds.Add(row.GetColumn(Sku).Value, pi); result = true; } return(result); }