private void Switch_Toggled(object sender, ToggledEventArgs e) { Model.GroceryItem item = (sender as Switch).Parent.BindingContext as Model.GroceryItem; if (item != null) { Task.Run(async() => await Model.ModelExtensions.PostItemToCollection <Model.GroceryItem>(groceryItemsListView, "shopping", item)); } }
public GroceryListPage() { InitializeComponent(); Command cmd = new Command(() => { string id = System.Guid.NewGuid().ToString(); Model.GroceryItem item = new Model.GroceryItem() { _id = id, what = groceryItem.Text, ownerId = "jac" }; Task.Run(async() => await Model.ModelExtensions.AddItemAndGetListItemsFromCollection <Model.GroceryItem>(groceryItemsListView, "shopping", item, true)); }); AddItem.Command = cmd; }