async Task CompleteItem(Yodel item) { item.Deleted = true; //item.Done = true; await manager.SaveYodelAsync(item); yodelList.ItemsSource = await manager.GetYodelsAsync(); }
public async void OnAdd(object sender, EventArgs e) { // Empty if (newItemName.Text.Length == 0) { YodelBar.IsVisible = false; ActionBar.IsVisible = true; return; } var locator = CrossGeolocator.Current; if (locator.IsGeolocationAvailable && locator.IsGeolocationEnabled) { locator.DesiredAccuracy = 50; labelGPS.Text = "Acquiring gps"; try { var position = await locator.GetPositionAsync(timeoutMilliseconds : 10000); if (position == null) { await DisplayAlert("GPS null", "Null GPS", "OK"); //labelGPS.Text = "null gps :("; return; } labelGPS.Text = string.Format("Time: {0} \nLat: {1} \nLong: {2} \n Altitude: {3} \nAltitude Accuracy: {4} \nAccuracy: {5} \n Heading: {6} \n Speed: {7}", position.Timestamp, position.Latitude, position.Longitude, position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading, position.Speed); var yodel = new Yodel { CreatedAt = DateTime.Now, Latitude = position.Latitude, Longitude = position.Longitude, Deleted = false, Message = newItemName.Text }; await AddItem(yodel); newItemName.Text = string.Empty; newItemName.Unfocus(); } catch (Exception ex) { await DisplayAlert("Geolocator Error", "Couldn't access GPS, did not Yodel", "OK"); } } else { await DisplayAlert("Location Error", "Couldn't access GPS, did not Yodel", "OK"); } YodelBar.IsVisible = false; ActionBar.IsVisible = true; }
public async Task SaveYodelAsync(Yodel item) { if (item.Id == null) { await yodelTable.InsertAsync(item); } else { await yodelTable.UpdateAsync(item); } }
// Data methods async Task AddItem(Yodel item) { await manager.SaveYodelAsync(item); yodelList.ItemsSource = await manager.GetYodelsAsync(); }