async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); var items = await ItemDataStore.GetItemsAsync(true); foreach (var item in items) { Items.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public ItemsViewModel() { Title = "Browse"; Items = new ObservableCollection <FirebaseObject <Item> >(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) => { var _item = item as Item; Items.Add(await ItemDataStore.AddAsync(_item)); }); }
public async void LoadItemId(string itemId) { try { var item = await ItemDataStore.GetItemAsync(itemId); Text = item.Text; Description = item.Description; Date = item.Date; Importance = item.Importance; Category = item.Category; } catch (Exception) { Debug.WriteLine("Failed to Load Item"); } }
public override Item CreateItem(Category category, string owner, string title, string description, string url, string urlName, DateTime newsDate) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ItemDataStore dataStore = new ItemDataStore(transaction); Item item = new Item(category, owner, title, description, url, urlName, newsDate); dataStore.Insert(item); transaction.Commit(); return item; } }
public override void DeleteItem(Item item) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ItemDataStore dataStore = new ItemDataStore(transaction); dataStore.Delete(item.Id); transaction.Commit(); } }
public override IList<Item> GetItems(Category category, PagingInfo paging) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ItemDataStore dataStore = new ItemDataStore(transaction); return dataStore.FindByCategory(category, paging); } }
public override Item GetItem(string id) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ItemDataStore dataStore = new ItemDataStore(transaction); return dataStore.FindByKey(id); } }
public override IList<Item> FindItems(Filter<string> categoryName, Filter<string> tag, DateTime? fromDate, DateTime? toDate, PagingInfo paging) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ItemDataStore dataStore = new ItemDataStore(transaction); return dataStore.FindByFields(categoryName, tag, fromDate, toDate, paging); } }
public async Task AddAsyncTest() { var dataStore = new ItemDataStore(new List <Item>()); await dataStore.AddAsync(new Item { Id = 1, Name = "Test1" }); }