/// <summary>
 /// Gets the database.
 /// </summary>
 /// <returns>The database.</returns>
 public static TodoItemDatabase GetDatabase()
 {
     if (instance == null)
     {
         instance = new TodoItemDatabase();
     }
     return(instance);
 }
        // 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();
            }
        }
Пример #4
0
 public static void SetDatabaseConnection(SQLite.Net.SQLiteConnection connection)
 {
     conn     = connection;
     database = new TodoItemDatabase(conn);
 }
Пример #5
0
		public static void SetDatabaseConnection (SQLite.Net.SQLiteConnection connection)
		{
			conn = connection;
			database = new TodoItemDatabase (conn);
		}
 // called when becoming visible
 protected override void OnAppearing()
 {
     base.OnAppearing();
     //refresh our items list
     Items = TodoItemDatabase.GetDatabase().GetItems();
 }
 /// <summary>
 /// Gets the database.
 /// </summary>
 /// <returns>The database.</returns>
 public static TodoItemDatabase GetDatabase()
 {
     if(instance == null)
         instance = new TodoItemDatabase();
     return instance;
 }