async Task ExecuteRefreshCommand(bool forceRefresh) { if (IsBusy) { return; } IsBusy = true; try { var position = await Geolocation.GetCurrentPositionAsync(); if (position == null) { throw new Exception("Unable to get location."); } Contacts.Clear(); var contacts = await DataService.GetNearbyAsync(position.Longitude, position.Latitude); if (contacts != null && contacts.Count() > 0) { Contacts.ReplaceRange(contacts); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"*** ERROR: {ex.Message}"); } finally { IsBusy = false; } }
async Task ExecuteRefreshCommand(bool forceRefresh) { if (IsBusy) { return; } if (!await CheckConnectivityAsync()) { return; } IsBusy = true; try { Analytics.TrackEvent("SerchedForNearby"); var position = await Geolocation.GetCurrentPositionAsync(); if (position == null) { throw new Exception("Unable to get location."); } ContactsGrouped.Clear(); var contacts = await DataService.GetNearbyAsync(position.Longitude, position.Latitude); if (contacts.Count() > 0) { ContactsGrouped.AddRange(contacts); } else { await Dialogs.AlertAsync(null, AppResources.NoCDAsNearby, AppResources.OK); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"*** ERROR: {ex.Message}"); } finally { IsBusy = false; } }