private IEnumerable <DescriptionRow> WriteLine(StopConnection connection)
        {
            var descriptionRows = new List <DescriptionRow>();
            var departureRow    = new DescriptionRow
            {
                First  = connection.StartDateTime.ToString(HOUR_FILTER),
                Second = connection.SourceStop.Stop.Name
            };
            var lineRow = new DescriptionRow
            {
                First  = $"{connection.Line.LineType} {connection.Line.Name}",
                Second = $"{DescriptionResources.Direction}: {_lineDirectionService.GetDirectionStop(connection.Line).Name}",
                Third  = $"{_timeCalculator.CalculateConnectionTime(connection).ToString()} " +
                         $"{DescriptionResources.Minutes}"
            };
            var arrivalRow = new DescriptionRow
            {
                First  = connection.EndDateTime.ToString(HOUR_FILTER),
                Second = connection.DestinationStop.Stop.Name
            };

            descriptionRows.Add(departureRow);
            descriptionRows.Add(lineRow);
            descriptionRows.Add(arrivalRow);
            return(descriptionRows);
        }
Exemplo n.º 2
0
        private IEnumerable <StopConnection> FlattenFastestPath
            (IList <StopConnection> fastestPath)
        {
            var flattenPath = new List <StopConnection>();

            foreach (var currentConnection  in fastestPath)
            {
                if (flattenPath.Count() > 0)
                {
                    if (!currentConnection.IsTransfer && !flattenPath.Last().IsTransfer)
                    {
                        var currentLine   = currentConnection.Line;
                        var lastAddedLine = flattenPath.Last().Line;
                        if (currentLine.Id == lastAddedLine.Id &&
                            _lineDirectionService.GetDirectionStop(currentLine).Id
                            == _lineDirectionService.GetDirectionStop(lastAddedLine).Id)
                        {
                            var lastAddedConnection = flattenPath.Last();
                            lastAddedConnection.DestinationStop = currentConnection.DestinationStop;
                            lastAddedConnection.EndDateTime     = currentConnection.EndDateTime;
                        }
                        else
                        {
                            flattenPath.Add(_cloner.CloneFrom(currentConnection));
                        }
                    }
                    else
                    {
                        flattenPath.Add(_cloner.CloneFrom(currentConnection));
                    }
                }
                else
                {
                    flattenPath.Add(_cloner.CloneFrom(currentConnection));
                }
            }
            return(flattenPath);
        }