Пример #1
0
        public async Task <IEnumerable <ArrivalTimeRespDto> > GetArrivalTimes(int routeId, DateTime startDate)
        {
            var tourEntity = await _tourRepository.LoadTour(routeId);

            var tour = _mappingService.MapToClass(tourEntity);

            _travelService.NormalizeStops(tour.TourStops);
            _travelService.CalculateTimeMatrix(tour);
            var timeTable = tour.GetTimeTable();

            var   arrivalTimes           = new Dictionary <Stop, DateTime>();
            float currentTotalTravelTime = 0;

            foreach (var stop in timeTable)
            {
                currentTotalTravelTime += stop.Value;
                arrivalTimes.Add(stop.Key, startDate.AddSeconds(currentTotalTravelTime));
            }

            return(_mappingService.MapToDto(arrivalTimes));
        }