コード例 #1
0
ファイル: ItemsViewModel.cs プロジェクト: Stahhl/EzTrain
        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;
            }
        }
コード例 #2
0
        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));
            });
        }
コード例 #3
0
        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");
            }
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        public override void DeleteItem(Item item)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                ItemDataStore dataStore = new ItemDataStore(transaction);

                dataStore.Delete(item.Id);

                transaction.Commit();
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        public override Item GetItem(string id)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                ItemDataStore dataStore = new ItemDataStore(transaction);

                return dataStore.FindByKey(id);
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
 public async Task AddAsyncTest()
 {
     var dataStore = new ItemDataStore(new List <Item>());
     await dataStore.AddAsync(new Item { Id = 1, Name = "Test1" });
 }