Exemplo n.º 1
0
        private void GetDataCommand(Item ShoppingItem)
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;

                if (!ShoppingItem.Status)
                {
                    ButtonName = "Remove from cart";
                }
                else
                {
                    ButtonName = "Add to cart";
                }

                var index = ShoppingItem.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;
                }

                ShoppingItem.Status = !ShoppingItem.Status;

                GenericMethods.CartCount();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception is " + ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
        private void OnButtonClickedCommand(Item ShoppingItem)
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;

                if (!ShoppingItem.Status)
                {
                    ButtonName = "Remove from cart";
                }
                else
                {
                    ButtonName = "Add to cart";
                }

                var index = ShoppingItem.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;
                }

                ShoppingItem.Status = !ShoppingItem.Status;

                GenericMethods.CartCount();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception is " + ex);
            }
            finally
            {
                IsBusy = false;
            }
        }