Пример #1
0
        private void MergeItems(Item updateItem)
        {
            //oldItem.Name = updateItem.Name;
            //oldItem.Price = updateItem.Price;

            ItemAccessManager.GetInstance().UpdateItem(updateItem);
        }
Пример #2
0
        public void UpdateItemsList(List <Item> lstNewItems)
        {
            foreach (Item item in lstNewItems)
            {
                Item itmOldItem = Items.FirstOrDefault(t =>
                                                       t.ItemId == item.ItemId);

                if (itmOldItem != null)
                {
                    MergeItems(item);
                }
                else
                {
                    //Items.Add(new Item(item.Name, item.Price, 0));
                    ItemAccessManager.GetInstance().AddItem(item);
                }
            }

            ObservableCollection <Item> ocTempItems =
                new ObservableCollection <Item>(Items);

            foreach (Item item in ocTempItems)
            {
                Item updateItem = lstNewItems.FirstOrDefault(t =>
                                                             t.ItemId == item.ItemId);

                // Check if the item has been deleted
                if (updateItem == null)
                {
                    //Items.Remove(item);
                    ItemAccessManager.GetInstance().DeleteItem(item);
                }
            }

            LoadItemsFromDB();
        }
Пример #3
0
 public void LoadItemsFromDB()
 {
     Items = new ObservableCollection <Item>(
         ItemAccessManager.GetInstance().GetAllItems());
 }