Exemple #1
0
        public void saveCartChecks(ItemModel obj)
        {
            // add new item to the cart
            if (Singleton.getCart().CartItemList.Where(x => x.Item.ID == obj.Item.ID).Count() == 0)
            {
                var cart_itemModel = new Cart_itemModel();
                obj.IsItemSelected         = true;
                cart_itemModel.Item        = obj.Item;
                cart_itemModel.TxtQuantity = 1.ToString();
                Singleton.getCart().AddItem(cart_itemModel);
            }

            // delete item from the cart
            else
            {
                // unselect item
                var itemFound = ItemModelList.Where(x => x.Item.ID == obj.Item.ID).FirstOrDefault();
                if (itemFound != null)
                {
                    itemFound.IsItemSelected = false;
                }

                foreach (var cart_itemModel in Singleton.getCart().CartItemList.Where(x => x.Item.ID == obj.Item.ID && x.TxtRef == obj.TxtRef).ToList())
                {
                    Singleton.getCart().RemoveItem(cart_itemModel);
                }
            }
            GoToQuoteCommand.raiseCanExecuteActionChanged();
        }
Exemple #2
0
        public async Task loadItemsAsync()
        {
            await Task.Factory.StartNew(() =>
            {
                Singleton.getDialogueBox().showSearch(ConfigurationManager.AppSettings["load_message"]);

                // if not in searching mode
                if (!_isSearchResult)
                {
                    var itemFoundList = Bl.BlItem.GetItemData(999);
                    ProviderList      = providerListToModelList(Bl.BlItem.GetProviderData(999));
                    FamilyList        = new HashSet <string>(itemFoundList.Select(x => x.Type_sub).ToList());
                    BrandList         = new HashSet <string>(itemFoundList.Select(x => x.Type).ToList());

                    // close items picture file before reloading
                    foreach (var itemModel in ItemModelList)
                    {
                        if (itemModel.Image != null)
                        {
                            itemModel.Image.closeImageSource();
                        }
                    }

                    // loading items
                    ItemModelList = itemListToModelViewList(itemFoundList);

                    // update the selected item in case of a refresh
                    if (SelectedItemModel != null && SelectedItemModel.Item.ID != 0)
                    {
                        SelectedItemModel = ItemModelList.Where(x => x.TxtID == SelectedItemModel.TxtID).SingleOrDefault();
                        if (SelectedItemModel != null)
                        {
                            SelectedItemModel.PropertyChanged -= ItemDetailViewModel.onItemNameChange_generateReference;
                            SelectedItemModel.PropertyChanged += ItemDetailViewModel.onItemNameChange_generateReference;
                        }
                    }
                    onPropertyChange("CurrencyModel");
                    _cbSearchCriteriaList = new List <string>();
                }
                _isSearchResult = false;
                Singleton.getDialogueBox().IsDialogOpen = false;
            });
        }