Пример #1
0
        private async Task GetDataCommand()
        {
            if (IsBusy)
            {
                return;
            }
            try
            {
                IsBusy = true;
                List <Item> ItemsList = await _Service.GetItems();



                for (int i = 0; i < ItemsList.Count; i++)
                {
                    if (ItemsList[i].Status)
                    {
                        ItemsList[i].ButtonText = "Remove";
                        Price += ItemsList[i].Price;

                        if (ItemsList[i].CustomStatus)
                        {
                            Price += ItemsList[i].CustomPrice;
                            ItemsList[i].CustomName1 = "Remove voice recognition";
                            ItemsList[i].CustomName2 = "Remove AI";
                            ItemsList[i].CustomName3 = "Remove dogs toy";
                        }
                    }

                    else
                    {
                        ItemsList[i].ButtonText = "Add to cart";
                    }
                }

                List <Item> UpdatedList = new List <Item>();

                UpdatedList = ItemsList.Where(item => item.Status).ToList <Item>();

                SetItems(UpdatedList);

                ShoppingItems.ReplaceRange(UpdatedList);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception is : " + e);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #2
0
        private async Task GetDataCommand()
        {
            if (IsBusy)
            {
                return;
            }
            try
            {
                IsBusy = true;
                List <Item> ItemsList = await _Service.GetItems();

                for (int i = 0; i < ItemsList.Count; i++)
                {
                    if (ItemsList[i].Status)
                    {
                        ItemsList[i].ButtonText = "Remove";
                    }
                    else
                    {
                        ItemsList[i].ButtonText = "Add to cart";
                    }
                }

                ShoppingItems.Clear();

                ShoppingItems.ReplaceRange(ItemsList);

                ShoppingItemsGrouped = new ObservableRangeCollection <Grouping <string, Item> >(GroupItems(ShoppingItems));

                CartCounter = GenericMethods.CartCount().ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception is : " + e);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #3
0
        private void ExecuteButtonClick(Object e)
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;

                var selectedItem = (Item)e;

                List <Item> ItemsList = new List <Item>(ShoppingItems);

                var index = selectedItem.Index;
                if (index == 1)
                {
                    Settings.ItemStatus1 = !Settings.ItemStatus1;
                }
                if (index == 2)
                {
                    Settings.ItemStatus2 = !Settings.ItemStatus2;
                }
                if (index == 3)
                {
                    Settings.ItemStatus3 = !Settings.ItemStatus3;
                }
                if (index == 4)
                {
                    Settings.ItemStatus4 = !Settings.ItemStatus4;
                }
                if (index == 5)
                {
                    Settings.ItemStatus5 = !Settings.ItemStatus5;
                }

                CartCounter = GenericMethods.CartCount().ToString();

                ShoppingItems.Clear();

                if (selectedItem.Status)
                {
                    ItemsList[index - 1].ButtonText = "Add to cart";
                }
                else
                {
                    ItemsList[index - 1].ButtonText = "Remove from cart";
                }

                selectedItem.Status = !selectedItem.Status;

                ShoppingItems.ReplaceRange(ItemsList);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception is " + ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #4
0
        private void ExecuteButtonClick(Object e)
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;

                var selectedItem = (Item)e;

                List <Item> ItemsList = new List <Item>(ShoppingItems);

                var index = selectedItem.Index;
                if (index == 1)
                {
                    Settings.ItemStatus1 = !Settings.ItemStatus1;
                }
                if (index == 2)
                {
                    Settings.ItemStatus2 = !Settings.ItemStatus2;
                }
                if (index == 3)
                {
                    Settings.ItemStatus3 = !Settings.ItemStatus3;
                }
                if (index == 4)
                {
                    Settings.ItemStatus4 = !Settings.ItemStatus4;
                }
                if (index == 5)
                {
                    Settings.ItemStatus5 = !Settings.ItemStatus5;
                }
                if (index == 6)
                {
                    Settings.ItemStatus6 = !Settings.ItemStatus6;
                }
                if (index == 7)
                {
                    Settings.ItemStatus7 = !Settings.ItemStatus7;
                }
                if (index == 8)
                {
                    Settings.ItemStatus8 = !Settings.ItemStatus8;
                }
                if (index == 9)
                {
                    Settings.ItemStatus9 = !Settings.ItemStatus9;
                }
                if (index == 10)
                {
                    Settings.ItemStatus10 = !Settings.ItemStatus10;
                }
                if (index == 11)
                {
                    Settings.ItemStatus11 = !Settings.ItemStatus11;
                }
                if (index == 12)
                {
                    Settings.ItemStatus12 = !Settings.ItemStatus12;
                }
                if (index == 13)
                {
                    Settings.ItemStatus13 = !Settings.ItemStatus13;
                }
                if (index == 14)
                {
                    Settings.ItemStatus14 = !Settings.ItemStatus14;
                }
                if (index == 15)
                {
                    Settings.ItemStatus15 = !Settings.ItemStatus15;
                }

                CartCounter = GenericMethods.CartCount().ToString();

                ShoppingItems.Clear();

                if (selectedItem.Status)
                {
                    ItemsList[index - 1].ButtonText = "Add to cart";
                }
                else
                {
                    ItemsList[index - 1].ButtonText = "Remove";
                }

                selectedItem.Status = !selectedItem.Status;

                ShoppingItems.ReplaceRange(ItemsList);

                ShoppingItemsGrouped = new ObservableRangeCollection <Grouping <string, Item> >(GroupItems(ShoppingItems));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception is " + ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #5
0
        private void ExecuteButtonClick(Object e)
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;

                var selectedItem = (Item)e;

                List <Item> ItemsList = new List <Item>(ShoppingItems);

                //Price = Price - ItemsList[selectedItem.Index].Price;

                var index = selectedItem.Index;

                if (index == 1)
                {
                    Settings.ItemStatus1 = !Settings.ItemStatus1;
                }
                if (index == 2)
                {
                    Settings.ItemStatus2 = !Settings.ItemStatus2;
                }
                if (index == 3)
                {
                    Settings.ItemStatus3 = !Settings.ItemStatus3;
                }
                if (index == 4)
                {
                    Settings.ItemStatus4 = !Settings.ItemStatus4;
                }
                if (index == 5)
                {
                    Settings.ItemStatus5 = !Settings.ItemStatus5;
                }
                if (index == 6)
                {
                    Settings.ItemStatus6 = !Settings.ItemStatus6;
                }
                if (index == 7)
                {
                    Settings.ItemStatus7 = !Settings.ItemStatus7;
                }
                if (index == 8)
                {
                    Settings.ItemStatus8 = !Settings.ItemStatus8;
                }
                if (index == 9)
                {
                    Settings.ItemStatus9 = !Settings.ItemStatus9;
                }
                if (index == 10)
                {
                    Settings.ItemStatus10 = !Settings.ItemStatus10;
                }
                if (index == 11)
                {
                    Settings.ItemStatus11 = !Settings.ItemStatus11;
                }
                if (index == 12)
                {
                    Settings.ItemStatus12 = !Settings.ItemStatus12;
                }
                if (index == 13)
                {
                    Settings.ItemStatus13 = !Settings.ItemStatus13;
                }
                if (index == 14)
                {
                    Settings.ItemStatus14 = !Settings.ItemStatus14;
                }
                if (index == 15)
                {
                    Settings.ItemStatus15 = !Settings.ItemStatus15;
                }



                ShoppingItems.Clear();

                selectedItem.Status = !selectedItem.Status;

                List <Item> UpdatedList = new List <Item>();

                UpdatedList = ItemsList.Where(item => item.Status).ToList <Item>();

                SetItems(UpdatedList);


                ShoppingItems.ReplaceRange(UpdatedList);
                Price  = Price - selectedItem.Price;
                Price -= selectedItem.CustomPrice;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception is " + ex);
            }
            finally
            {
                IsBusy = false;
            }
        }