async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Tasks.Clear(); var items = await ToDoDataStore.GetItemsAsync(); foreach (var item in items) { Tasks.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public ToDoDataStoreTests() { _toDoDataStore = new ToDoDataStore( _cosmosClient, _configuration["COSMOSDB_DATABASEID"]); _toDoDataContainer = _cosmosClient .GetDatabase(_configuration["COSMOSDB_DATABASEID"]) .GetContainer("toDos"); }
public ToDoTaskViewModel() { Title = "Browse"; Tasks = new ObservableCollection <ToDoTask>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <NewToDoTaskPage, ToDoTask>(this, "AddTask", async(obj, task) => { var _task = task as ToDoTask; Tasks.Add(_task); await ToDoDataStore.SaveItemAsync(_task); }); }