public async Task SetupGeofencesAsync(SetupGeofencingMessage message)
        {
            foreach (var mapFriendViewModel in message.MapFriendViewModel.Where(f => f.Location != null))
            {
                var geofence = new Geofence(mapFriendViewModel.Id, new Geocircle(mapFriendViewModel.Location.Position, 2000), MonitoredGeofenceStates.Entered, false);
                if (geofences.SingleOrDefault(g => g.Id == geofence.Id) == null)
                    geofences.Add(geofence);
            }

            var settings = ApplicationData.Current.LocalSettings;
            var jsonsString = settings.Values["BackgroundGeofenceEventCollection"];

            await RegisterBackgroundTask();
        }
Example #2
0
        private async Task GetFriendsAsync()
        {
            var friends = await friendService.GetFriendsAsync();
            this.friends.Clear();
            foreach (var friend in friends)
            {
                this.friends.Add(new MapFriendViewModel
                {
                    Id = friend.Id,
                    FirstName = friend.FirstName,
                    LastName = friend.LastName,
                    LastUpdated = friend.Location != null ? friend.Location.LastUpdated : DateTime.MinValue,
                    Location = friend.Location.ToGeolocation()
                });
            }

            AddMe();

            var geofenceMessage = new SetupGeofencingMessage(this.friends);
            Messenger.Default.Send(geofenceMessage);
        }