Пример #1
0
        public async Task <FindPathModel> GetPathBetweenTwoStationsAsync(int startStationId, int endStationId)
        {
            var routes = await _dictionariesCacheHelper.GetAllActiveRoutesWithStations();

            var findResult = FindRouteHelper.GetPaths(routes, startStationId, endStationId);

            var result = new FindPathModel()
            {
                DirectDirections      = MapToRouteDirectionApiModel(findResult.DirectDirections),
                OneTransferDirections = findResult.OneTransferDirections.Select(MapToRouteDirectionApiModel).ToList()
            };

            return(result);
        }
Пример #2
0
        public async Task <FindPathModel> GetPathBetweenTwoStationsAsync(int startStationId, int endStationId)
        {
            var cacheKey = $"GetPathBetweenTwoStations_{startStationId}_{endStationId}";

            var findResult = await _appCacheHelper.GetCachedAsync(
                cacheKey,
                async() =>
            {
                var newRoutes = await _dictionariesCacheHelper.GetAllNewRoutesWithStations();
                var oldRoutes = await _dictionariesCacheHelper.GetAllActiveRoutesWithStations();

                return(FindRouteHelper.GetPaths(newRoutes, oldRoutes, startStationId, endStationId));
            },
                _newRoutesCacheClearTypes);

            var result = new FindPathModel()
            {
                DirectDirections      = MapToRouteDirectionApiModel(findResult.DirectDirections),
                OneTransferDirections = findResult.OneTransferDirections.Select(MapToRouteDirectionApiModel).ToList()
            };

            return(result);
        }