@@ -120,7 +120,7 @@ protected async Task<DialogTurnResult> ConfirmCurrentLocation(WaterfallStepConte
120120 var service = ServiceManager . InitAddressMapsService ( Settings ) ;
121121
122122 var pointOfInterestList = await service . GetPointOfInterestListByAddressAsync ( double . NaN , double . NaN , sc . Result . ToString ( ) ) ;
123- var cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList ) ;
123+ var cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList , service ) ;
124124
125125 if ( cards . Count ( ) == 0 )
126126 {
@@ -247,7 +247,7 @@ protected async Task<DialogTurnResult> ProcessCurrentLocationSelection(Waterfall
247247 {
248248 // No entities identified, find nearby locations
249249 pointOfInterestList = await service . GetNearbyPointOfInterestListAsync ( state . CurrentCoordinates . Latitude , state . CurrentCoordinates . Longitude ) ;
250- cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList ) ;
250+ cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList , service ) ;
251251 }
252252 else if ( ! string . IsNullOrEmpty ( state . Keyword ) && ! string . IsNullOrEmpty ( state . Address ) )
253253 {
@@ -258,26 +258,26 @@ protected async Task<DialogTurnResult> ProcessCurrentLocationSelection(Waterfall
258258 {
259259 var pointOfInterest = pointOfInterestAddressList [ 0 ] ;
260260 pointOfInterestList = await service . GetPointOfInterestListByQueryAsync ( pointOfInterest . Geolocation . Latitude , pointOfInterest . Geolocation . Longitude , state . Keyword ) ;
261- cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList ) ;
261+ cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList , service ) ;
262262 }
263263 else
264264 {
265265 // No POIs found from address - search near current coordinates
266266 pointOfInterestList = await service . GetPointOfInterestListByQueryAsync ( state . CurrentCoordinates . Latitude , state . CurrentCoordinates . Longitude , state . Keyword ) ;
267- cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList ) ;
267+ cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList , service ) ;
268268 }
269269 }
270270 else if ( ! string . IsNullOrEmpty ( state . Keyword ) )
271271 {
272272 // Fuzzy query search with keyword
273273 pointOfInterestList = await service . GetPointOfInterestListByQueryAsync ( state . CurrentCoordinates . Latitude , state . CurrentCoordinates . Longitude , state . Keyword ) ;
274- cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList ) ;
274+ cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList , service ) ;
275275 }
276276 else if ( ! string . IsNullOrEmpty ( state . Address ) )
277277 {
278278 // Fuzzy query search with address
279- pointOfInterestList = await service . GetPointOfInterestListByAddressAsync ( state . CurrentCoordinates . Latitude , state . CurrentCoordinates . Longitude , state . Address ) ;
280- cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList ) ;
279+ pointOfInterestList = await addressMapsService . GetPointOfInterestListByAddressAsync ( state . CurrentCoordinates . Latitude , state . CurrentCoordinates . Longitude , state . Address ) ;
280+ cards = await GetPointOfInterestLocationCards ( sc , pointOfInterestList , addressMapsService ) ;
281281 }
282282
283283 if ( cards . Count ( ) == 0 )
@@ -457,25 +457,17 @@ protected async Task<List<PointOfInterestModel>> CurrentLocationValidator(Prompt
457457 return await Task . FromResult ( pointOfInterestList ) ;
458458 }
459459
460- protected async Task < List < Card > > GetPointOfInterestLocationCards ( DialogContext sc , List < PointOfInterestModel > pointOfInterestList )
460+ // service: for details. the one generates pointOfInterestList
461+ protected async Task < List < Card > > GetPointOfInterestLocationCards ( DialogContext sc , List < PointOfInterestModel > pointOfInterestList , IGeoSpatialService service )
461462 {
462463 var state = await Accessor . GetAsync ( sc . Context ) ;
463- var service = ServiceManager . InitMapsService ( Settings ) ;
464- var addressService = ServiceManager . InitAddressMapsService ( Settings ) ;
465464 var cards = new List < Card > ( ) ;
466465
467466 if ( pointOfInterestList != null && pointOfInterestList . Count > 0 )
468467 {
469468 for ( var i = 0 ; i < pointOfInterestList . Count ; i ++ )
470469 {
471- if ( sc . ActiveDialog . Id . Equals ( Actions . CheckForCurrentLocation ) )
472- {
473- pointOfInterestList [ i ] = await addressService . GetPointOfInterestDetailsAsync ( pointOfInterestList [ i ] ) ;
474- }
475- else
476- {
477- pointOfInterestList [ i ] = await service . GetPointOfInterestDetailsAsync ( pointOfInterestList [ i ] ) ;
478- }
470+ pointOfInterestList [ i ] = await service . GetPointOfInterestDetailsAsync ( pointOfInterestList [ i ] ) ;
479471
480472 // Increase by one to avoid zero based options to the user which are confusing
481473 pointOfInterestList [ i ] . Index = i + 1 ;
0 commit comments