public ShipmentFileExportRow(IReadOnlyList <string> rawShipmentData, ISmartShipmentExportParametersParser exportParametersParser)
 {
     ShipmentNbr            = exportParametersParser.Trim(rawShipmentData[0]);
     RowNumber              = exportParametersParser.ParseRowNumber(rawShipmentData[1]);
     ShipmentTrackingNumber = exportParametersParser.Trim(rawShipmentData[2]);
     PackageTrackingNumber  = exportParametersParser.Trim(rawShipmentData[3]);
     FreightCost            = exportParametersParser.ParseDecimal((rawShipmentData[4]));
     ShipmentDate           = exportParametersParser.ParseShipmentDateTime(rawShipmentData[5]);
     PackageWeight          = exportParametersParser.ParseDecimal(rawShipmentData[6]);
     VoidIndicator          = exportParametersParser.ParseVoidIndicator(rawShipmentData[7]);
 }
Esempio n. 2
0
        public static IEnumerable <ShipmentFileExportRow> ToShipmentExportedRows(this IEnumerable <string> rawDataShipment, ISmartShipmentExportParametersParser exportParametersParser)
        {
            var shipmentFileExportRows = rawDataShipment.Select(rawShipment => rawShipment.StringToRawShipmentRow())
                                         .Where(rawShipment => rawShipment.Length == COL_LENGTH)
                                         .Select(rawShipment => new ShipmentFileExportRow(rawShipment, exportParametersParser))
                                         .ToList();

            //Try to set shipmentNbr to all row
            foreach (var shipmentTrackingGroup in shipmentFileExportRows.GroupBy(s => s.ShipmentTrackingNumber))
            {
                var shipmentFileExportRow = shipmentTrackingGroup.FirstOrDefault(s => !string.IsNullOrEmpty(s.ShipmentNbr));
                if (shipmentFileExportRow != null)
                {
                    var shipmentNbr = shipmentFileExportRow.ShipmentNbr;
                    foreach (var row in shipmentTrackingGroup.Where(row => string.IsNullOrEmpty(row.ShipmentNbr)))
                    {
                        row.ShipmentNbr = shipmentNbr;
                    }
                }
            }

            return(shipmentFileExportRows);
        }