Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created March 4, 2025 21:38
Show Gist options
  • Save dcomartin/535fb080715f0b04d5c39253960a289d to your computer and use it in GitHub Desktop.
Save dcomartin/535fb080715f0b04d5c39253960a289d to your computer and use it in GitHub Desktop.
public double ShipmentDistance(ExternalShipment shipment)
{
var miles = shipment.Stops.Sum(x => x.Miles);
return MilesToKilometers(miles);
}
public double TollDistance(ExternalShipment shipment)
{
var miles = shipment.Stops
.Where(x => x.HasTolls)
.Sum(x => x.Miles);
return MilesToKilometers(miles);
}
private double MilesToKilometers(double miles)
{
return miles * 1.60934;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment