Example #1
0
        public async void SyncShoppingList()
        {
            IsSyncInProgress = true;

            var  currentShoppingList = _settings.ShoppingListItems.AsObservableList().Items;
            bool success             = await _oneNoteService.UpdateShoppingListContent(currentShoppingList.Select(x => x.AsOneNoteCheckboxNode()));

            if (success)
            {
                await Task.Delay(3000); // Kind of a hack, but we're going to give the server a moment to update itself.

                // Not truly a for-loop--just an easy way to match against a Some() value. Should only ever "loop" once.
                foreach (IEnumerable <OneNoteCheckboxNode> someValue in (await _oneNoteService.GetShoppingListPageContent()))
                {
                    // TODO: Handle getting item types that we don't have locally

                    var newList = someValue
                                  .Where(x => !x.IsChecked)
                                  .Select(x => x.AsShoppingListEntry())
                                  .Select(x => x.ValueOr(alternative: null))
                                  .Where(x => x != null);

                    _settings.ClearShoppingListItems();
                    _settings.AddToShoppingList(newList);
                }
            }

            IsSyncInProgress = false;
        }
Example #2
0
 private void AddToShoppingList()
 {
     _settings.AddToShoppingList(Entry);
 }