private async void EndSurveyCommandExecute()
        {
            var newSurvey = new Survey()
            {
                Id        = Guid.NewGuid().ToString(),
                Name      = Name,
                Birthdate = Birthdate,
                TeamId    = localDbTeams.First(t => t.Name == Team).Id
            };

            var geolocationService = Xamarin.Forms.DependencyService.Get <IGeolocationService>();

            if (geolocationService != null)
            {
                try
                {
                    var currentLocation = await geolocationService.GetCurrentLocationAsync();

                    newSurvey.Latitude  = currentLocation.Item1;
                    newSurvey.Longitude = currentLocation.Item2;
                }
                catch (Exception)
                {
                    newSurvey.Latitude  = 0;
                    newSurvey.Longitude = 0;
                }
            }

            await localDbService.InsertSurveyAsync(newSurvey);

            await navigationService.GoBackAsync();
        }
Пример #2
0
        //private void SurveyDetailListView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        //{
        //    if (e.PropertyName == nameof(FavoriteTeam))
        //    {
        //        (EndSurveyCommand as Command)?.ChangeCanExecute();
        //    }
        //}
        private async void EndSurveyCommandExcecute()
        {
            var newSurvey = new Survey
            {
                Id           = Guid.NewGuid().ToString(),
                Name         = Name,
                BirthDate    = BirthDate,
                FavoriteTeam = FavoriteTeam,
                TeamId       = localDbTeams.First(t => t.Name == favoriteTeam).Id
            };
            var geoLocationService = Xamarin.Forms.DependencyService.Get <IGeolocationService>();

            if (geoLocationService != null)
            {
                try
                {
                    var currentLocation = await geoLocationService.GetCurrentLocationAsync();

                    newSurvey.Lat = currentLocation.Item1;
                    newSurvey.Lon = currentLocation.Item2;
                }
                catch
                {
                    newSurvey.Lat = 0;
                    newSurvey.Lon = 0;
                }
            }
            //MessagingCenter.Send(this, Messages.NewSurveyComplete, newSurvey);
            await localDbService.InsertSurveyAsync(newSurvey);

            await navigationService.GoBackAsync();
        }