public static bool ArePreviousStopsInZone(this ManifestLegs manifestLegs, int startIndex, bool allStopsInZoneRequired, bool failIfNoPreviousStops)
        {
            var result = !failIfNoPreviousStops;

            for (int i = startIndex; i >= 0; i--)
            {
                var leg      = manifestLegs.AllLegs[i];
                var isInZone = ValidValues.IsValidZipCode(leg.CompanyZipInt);

                if (!allStopsInZoneRequired && isInZone)
                {
                    return(true);
                }

                if (allStopsInZoneRequired && !isInZone)
                {
                    return(false);
                }

                if (isInZone)
                {
                    result = true;
                }
            }

            return(result);
        }
        public static int AllLegsGetNextStopInZone(this ManifestLegs manifestLegs, int startIndex = 0)
        {
            for (int i = startIndex; i < manifestLegs.AllLegs.Count; i++)
            {
                if (ValidValues.IsValidZipCode(manifestLegs.AllLegs[i].CompanyZipInt))
                {
                    return(i);
                }
            }

            return(-1);
        }
        public static ImportedLeg GetMiamiRailLegAfterCustomers(this ManifestLegs manifestLegs)
        {
            bool foundCustomer = false;

            foreach (var leg in manifestLegs.AllLegs)
            {
                if (!leg.IsRail() && ValidValues.IsValidZipCode(leg.CompanyZipInt))
                {
                    foundCustomer = true;
                    continue;
                }

                if (foundCustomer && leg.IsMiamiRail())
                {
                    return(leg);
                }
            }

            return(null);
        }
        public static ImportedLeg GetMiamiRailLegBeforeCustomers(this ManifestLegs manifestLegs)
        {
            bool foundCustomer = false;

            for (int i = manifestLegs.AllLegs.Count - 1; i >= 0; i--)
            {
                var leg = manifestLegs.AllLegs[i];
                if (!leg.IsRail() && ValidValues.IsValidZipCode(leg.CompanyZipInt))
                {
                    foundCustomer = true;
                    continue;
                }

                if (foundCustomer && leg.IsMiamiRail())
                {
                    return(leg);
                }
            }

            return(null);
        }
 public static bool MatchesZipRange(this ImportedLeg leg)
 {
     return(leg.CompanyZipInt > 0 && ValidValues.IsValidZipCode(leg.CompanyZipInt));
 }