Ejemplo n.º 1
0
        /// <summary>
        /// Remove <see cref="ArticleItemDataModel"/> from checkout
        /// </summary>
        /// <param name="arg"></param>
        public void RemoveFromCheckoutAction(object arg)
        {
            ArticleItemDataModel item = (ArticleItemDataModel)arg;

            var articleToRemove = Checkout.First(a => a.Article.ID == item.Article.ID);

            if (articleToRemove != null)
            {
                Checkout.Remove(articleToRemove);
            }

            //
            RemoveFromCheckoutSum((float)articleToRemove.Article.BasePrice);

            // Recount the checkout item
            NumberOfItemsInCheckout = Checkout.Count();

            //Safety check for negatives, maybe not needed
            if (NumberOfItemsInCheckout < 0)
            {
                NumberOfItemsInCheckout = 0;
            }

            // Disable the buy button
            if (NumberOfItemsInCheckout < 1)
            {
                BuyButtonEnabledMode = "False";
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        private async void CreateNewCustomArticleAction(object args)
        {
            // Filter out unchecked ingredients
            var selectedIngredients = Ingredients.Where(a => a.IsChecked);
            // Initiate new Article model
            var newArticle = await Global.ArticleRepo.GetAsync(80);

            foreach (var item in Ingredients)
            {
                newArticle.Ingredients.Add(new Ingredient {
                    ID = item.ID, Name = item.Name, Price = item.Price
                });
                newArticle.BasePrice += item.Price;
            }

            // Inside the wrapper thingy
            var articleItemDataModel = new ArticleItemDataModel(newArticle);

            // Add to checkout
            AddToCheckoutAction(articleItemDataModel);

            // Reset for next custom article
            ResetIngredients();
        }