diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/FindParkingDialog.cs b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/FindParkingDialog.cs index e613db07c4..c9d7345658 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/FindParkingDialog.cs +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/FindParkingDialog.cs @@ -116,20 +116,20 @@ protected async Task RouteToFindFindParkingDialog(WaterfallSte { var pointOfInterest = pointOfInterestAddressList[0]; pointOfInterestList = await mapsService.GetPointOfInterestListByParkingCategoryAsync(pointOfInterest.Geolocation.Latitude, pointOfInterest.Geolocation.Longitude); - cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, mapsService); } else { // Find parking lot near address pointOfInterestList = await mapsService.GetPointOfInterestListByParkingCategoryAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude); - cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, mapsService); } } else { // No entities identified, find nearby parking lots pointOfInterestList = await mapsService.GetPointOfInterestListByParkingCategoryAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude); - cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, mapsService); } if (cards.Count == 0) diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/PointOfInterestDialogBase.cs b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/PointOfInterestDialogBase.cs index 9c34bee9c0..e3b5c889aa 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/PointOfInterestDialogBase.cs +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/PointOfInterestDialogBase.cs @@ -120,7 +120,7 @@ protected async Task ConfirmCurrentLocation(WaterfallStepConte var service = ServiceManager.InitAddressMapsService(Settings); var pointOfInterestList = await service.GetPointOfInterestListByAddressAsync(double.NaN, double.NaN, sc.Result.ToString()); - var cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + var cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service); if (cards.Count() == 0) { @@ -247,7 +247,7 @@ protected async Task ProcessCurrentLocationSelection(Waterfall { // No entities identified, find nearby locations pointOfInterestList = await service.GetNearbyPointOfInterestListAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude); - cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service); } else if (!string.IsNullOrEmpty(state.Keyword) && !string.IsNullOrEmpty(state.Address)) { @@ -258,26 +258,26 @@ protected async Task ProcessCurrentLocationSelection(Waterfall { var pointOfInterest = pointOfInterestAddressList[0]; pointOfInterestList = await service.GetPointOfInterestListByQueryAsync(pointOfInterest.Geolocation.Latitude, pointOfInterest.Geolocation.Longitude, state.Keyword); - cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service); } else { // No POIs found from address - search near current coordinates pointOfInterestList = await service.GetPointOfInterestListByQueryAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude, state.Keyword); - cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service); } } else if (!string.IsNullOrEmpty(state.Keyword)) { // Fuzzy query search with keyword pointOfInterestList = await service.GetPointOfInterestListByQueryAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude, state.Keyword); - cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service); } else if (!string.IsNullOrEmpty(state.Address)) { // Fuzzy query search with address - pointOfInterestList = await service.GetPointOfInterestListByAddressAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude, state.Address); - cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList); + pointOfInterestList = await addressMapsService.GetPointOfInterestListByAddressAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude, state.Address); + cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, addressMapsService); } if (cards.Count() == 0) @@ -457,25 +457,17 @@ protected async Task> CurrentLocationValidator(Prompt return await Task.FromResult(pointOfInterestList); } - protected async Task> GetPointOfInterestLocationCards(DialogContext sc, List pointOfInterestList) + // service: for details. the one generates pointOfInterestList + protected async Task> GetPointOfInterestLocationCards(DialogContext sc, List pointOfInterestList, IGeoSpatialService service) { var state = await Accessor.GetAsync(sc.Context); - var service = ServiceManager.InitMapsService(Settings); - var addressService = ServiceManager.InitAddressMapsService(Settings); var cards = new List(); if (pointOfInterestList != null && pointOfInterestList.Count > 0) { for (var i = 0; i < pointOfInterestList.Count; i++) { - if (sc.ActiveDialog.Id.Equals(Actions.CheckForCurrentLocation)) - { - pointOfInterestList[i] = await addressService.GetPointOfInterestDetailsAsync(pointOfInterestList[i]); - } - else - { - pointOfInterestList[i] = await service.GetPointOfInterestDetailsAsync(pointOfInterestList[i]); - } + pointOfInterestList[i] = await service.GetPointOfInterestDetailsAsync(pointOfInterestList[i]); // Increase by one to avoid zero based options to the user which are confusing pointOfInterestList[i].Index = i + 1;