Example #1
0
        private void RemoveAllItems()
        {
            if (IsBusy)
            {
                return;
            }
            try
            {
                IsBusy = true;

                Settings.ItemStatus1        = false;
                Settings.ItemStatus2        = false;
                Settings.ItemStatus3        = false;
                Settings.ItemStatus4        = false;
                Settings.ItemStatus5        = false;
                Settings.ItemStatus6        = false;
                Settings.ItemStatus7        = false;
                Settings.ItemStatus8        = false;
                Settings.ItemStatus9        = false;
                Settings.ItemStatus10       = false;
                Settings.ItemStatus11       = false;
                Settings.ItemStatus12       = false;
                Settings.ItemStatus13       = false;
                Settings.ItemStatus14       = false;
                Settings.ItemStatus15       = false;
                Settings.ItemCustomStatus1  = false;
                Settings.ItemCustomStatus2  = false;
                Settings.ItemCustomStatus3  = false;
                Settings.ItemCustomStatus4  = false;
                Settings.ItemCustomStatus5  = false;
                Settings.ItemCustomStatus6  = false;
                Settings.ItemCustomStatus7  = false;
                Settings.ItemCustomStatus8  = false;
                Settings.ItemCustomStatus9  = false;
                Settings.ItemCustomStatus10 = false;
                Settings.ItemCustomStatus11 = false;
                Settings.ItemCustomStatus12 = false;
                Settings.ItemCustomStatus13 = false;
                Settings.ItemCustomStatus14 = false;
                Settings.ItemCustomStatus15 = false;

                Price = 0;

                ShoppingItems.Clear();

                ItemsInCart   = false;
                NoItemsInCart = true;
                Price         = 0;

                Analytics.TrackEvent("Remove all items from cart clicked");
            }
            catch (Exception e)
            {
                Console.Write("Exception is " + e);
            }
            finally
            {
                IsBusy = false;
            }
        }
 private void ButtonConfirmOrder_Click(object sender, RoutedEventArgs e)
 {
     if (ShoppingItems.Count <= 0)
     {
         return;
     }
     try
     {
         DB.SubtractItemsFromWarehouse(ShoppingItems);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Errore durante la connessione al Database: " + Environment.NewLine + ex.Message,
                         "Errore", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     try
     {
         DB.RegisterOrder(ShoppingItems);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Errore durante la connessione al Database: " + Environment.NewLine + ex.Message,
                         "Errore", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     ShoppingItems.Clear();
     RefreshWarehouse();
     TotalPrice = 0;
 }
        private async Task ExecuteLoadShoppingItemsCommand()
        {
            IsBusy = true;

            try
            {
                ShoppingItems.Clear();
                System.Collections.Generic.IEnumerable <ShoppingItem> items;
                if (selectedMode == Mode.Modify)
                {
                    items = await ShoppingListDataStore.GetShoppingItemsAsync(shoppingListId);
                }
                else
                {
                    items = await ShoppingListDataStore.GetShoppingItemsOrderBySortKeyAsync(shoppingListId);
                }
                foreach (ShoppingItem item in items)
                {
                    ShoppingItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        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;
            }
        }
 private void ButtonCancelOrder_OnClick(object sender, RoutedEventArgs e)
 {
     ShoppingItems.Clear();
     TotalPrice = 0;
 }
Example #6
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;
            }
        }
        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;
            }
        }
Example #8
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;
            }
        }