/// <summary>
        /// Saves the amount of ingredients
        /// </summary>
        private void SaveExecute()
        {
            try
            {
                if (addIngredientAmountToShoppingBasket.txtQuantity.Text.Length < 1)
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Unesite broj.", "Pogresan unos", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                if (addIngredientAmountToShoppingBasket.txtQuantity.Text.ToString() == "0" || addIngredientAmountToShoppingBasket.txtQuantity.Text.ToString() == "00")
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Kolicina mora biti veca od nule.", "Pogresan unos", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                ItemAmount.UserID       = LoggedGuest.ID;
                ItemAmount.IngredientID = Ingredient.IngredientID;
                ItemAmount.Amount       = Amount;
                shoppingData.AddShoppingList(ItemAmount);
                addIngredientAmountToShoppingBasket.Close();
            }
            catch (Exception)
            {
                MessageBoxResult dialog = Xceed.Wpf.Toolkit.MessageBox.Show("Trenutno je nemoguce dodati sastojak...", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method for adding the selected item from the list
        /// </summary>
        public void AddShoppingItemExecute()
        {
            try
            {
                List <tblShoppingBasket>    tempShoppingList            = shoppingData.GetAllSelectedShoppingBasketItems(LoggedGuest.ID).ToList();
                AddIngredientToRecipe       addIngredientToBasket       = new AddIngredientToRecipe();
                AddIngredientToRecipeWindow addIngredientToRecipeWindow = new AddIngredientToRecipeWindow();
                addIngredientToRecipeWindow.ShowDialog();
                // addIngredientToBasket.ShowDialog();

                // Return the list to the initial state
                if (isShoppingListNotUpdated == true)
                {
                    for (int i = 0; i < tempShoppingList.Count; i++)
                    {
                        tempShoppingList[i].ShoppingBasketID = 0;
                        tempShoppingList[i].UserID           = LoggedGuest.ID;
                        shoppingData.AddShoppingList(tempShoppingList[i]);
                    }
                    isShoppingListNotUpdated = false;
                }

                ShoppingBasketList = shoppingData.GetAllSelectedShoppingBasketItems(LoggedGuest.ID).ToList();
            }
            catch (Exception)
            {
                MessageBoxResult dialog = Xceed.Wpf.Toolkit.MessageBox.Show("Trenutno je nemoguce dodati sastojak...", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }