// Saves the item to the database public void OnSave(object sender, EventArgs e) { if (!Validate()) { return; } TodoItemDatabase.GetDatabase().SaveItem(Model); Navigation.PopAsync(); }
//On Delete. The async operator allows us to use the await operator in our method. public async void OnDelete(object sender, EventArgs e) { // Display a popup var answer = await DisplayAlert("Are You Sure?", "This data will be lost forever and ever and ever.", "Delete", "NO NO NO"); //if true, delete the item if (answer) { TodoItemDatabase.GetDatabase().DeleteItem(Model.ID); // back button await Navigation.PopAsync(); } }
// called when becoming visible protected override void OnAppearing() { base.OnAppearing(); //refresh our items list Items = TodoItemDatabase.GetDatabase().GetItems(); }