コード例 #1
0
        /// <summary>
        /// Handles Adding Pizza To the temp Cart: pass the PizzaSizeId
        /// Used to update Order Items Datasource for UI binding and Tax Computaion
        /// Sets ItemIsATopping = false,
        /// </summary>
        /// <param name="selectedPizzaTopping"></param>
        /// <returns></returns>
        private void AddPizzaToCartTask(int selectedPizzaSize)
        {
            PizzaCatalogModel pizza = (from p in _dbContext.Pizzas
                                       join pz in _dbContext.PizzaSizes on p.PizzaSizeId equals pz.Id
                                       where p.PizzaSizeId == selectedPizzaSize
                                       select new PizzaCatalogModel
            {
                PizzaSize = p.PizzaSize,
                Id = p.Id,
                PizzaSizeId = p.PizzaSizeId,
                Price = p.Price,
            }).FirstOrDefault();
            List <Cart> list = CartItems != null?CartItems.ToList() : new List <Cart>();

            Cart cart = new Cart
            {
                ItemName       = pizza.PizzaSize.Name,
                ItemId         = pizza.Id,
                PizzaSizeId    = pizza.PizzaSizeId,
                Price          = pizza.Price,
                ItemIsATopping = false
            };

            list.Add(cart);
            var price = Math.Round(list.Sum(s => s.Price), 2);

            this.SubTotalPrice = (price * 0.95);
            this.TotalGST      = price - SubTotalPrice;
            this.TotalPrice    = price;
            CartItems          = (IEnumerable <Cart>)list;
        }
コード例 #2
0
 private void OnClearExecute(object obj)
 {
     _chainOneTotal   = 0;
     _chainTwoTotal   = 0;
     _chainThreeTotal = 0;
     OnPropertyChanged(nameof(ChainOneTotal));
     OnPropertyChanged(nameof(ChainTwoTotal));
     OnPropertyChanged(nameof(ChainThreeTotal));
     _eventAggregator.GetEvent <ClearCartEvent>().Publish(CartItems.ToList());
     CartItems.Clear();
     ClearLowAndHighCollections();
 }
コード例 #3
0
        private void UpdateLowAndHighPrices()
        {
            ChainOneHigh.Clear();
            var resultOneHigh = _dataProvider.GetHighPricesInChainOne(CartItems.ToList());

            foreach (var item in resultOneHigh)
            {
                ChainOneHigh.Add(item);
            }
            ChainOneLow.Clear();
            var resultOneLow = _dataProvider.GetLowPricesInChainOne(CartItems.ToList());

            foreach (var item in resultOneLow)
            {
                ChainOneLow.Add(item);
            }
            ChainTwoHigh.Clear();
            var resultTwoHigh = _dataProvider.GetHighPricesInChainTwo(CartItems.ToList());

            foreach (var item in resultTwoHigh)
            {
                ChainTwoHigh.Add(item);
            }
            ChainTwoLow.Clear();
            var resultTwoLow = _dataProvider.GetLowPricesInChainTwo(CartItems.ToList());

            foreach (var item in resultTwoLow)
            {
                ChainTwoLow.Add(item);
            }
            ChainThreeHigh.Clear();
            var resultThreeHigh = _dataProvider.GetHighPricesInChainThree(CartItems.ToList());

            foreach (var item in resultThreeHigh)
            {
                ChainThreeHigh.Add(item);
            }
            ChainThreeLow.Clear();
            var resultThreeLow = _dataProvider.GetLowPricesInChainThree(CartItems.ToList());

            foreach (var item in resultThreeLow)
            {
                ChainThreeLow.Add(item);
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles Adding Toppings To the temp Cart: pass the ToppingsId
        /// Used to update Order Items Datasource for UI binding and Tax Computaion
        /// Sets ItemIsATopping = true,
        /// </summary>
        /// <param name="selectedPizzaTopping"></param>
        /// <returns></returns>
        private Task AddToppingsToCartTask(object selectedPizzaTopping)
        {
            ToppingCatalogModel topping = (from p in _dbContext.Toppings
                                           join tc in _dbContext.ToppingCategories on p.ToppingCategoryId equals tc.Id
                                           join pz in _dbContext.PizzaSizes on p.PizzaSizeId equals pz.Id
                                           where p.Id == (int)selectedPizzaTopping
                                           select new ToppingCatalogModel
            {
                PizzaSize = p.PizzaSize,
                Id = p.Id,
                PizzaSizeId = p.PizzaSizeId,
                Price = p.Price,
                Name = p.Name,
                ToppingCategoryId = p.ToppingCategoryId,
                ToppingCategory = p.ToppingCategory
            }).FirstOrDefault();
            List <Cart> list = CartItems != null?CartItems.ToList() : new List <Cart>();

            Cart cart = new Cart
            {
                ItemName       = string.Format("{0}-{1}", topping.PizzaSize.Name, topping.Name),
                ItemId         = topping.Id,
                PizzaSizeId    = topping.PizzaSizeId,
                Price          = topping.Price,
                ItemIsATopping = true,
            };

            list.Add(cart);
            var price = list.Sum(s => s.Price);

            this.SubTotalPrice = (price * 0.95);
            this.TotalGST      = price - SubTotalPrice;
            this.TotalPrice    = price;
            CartItems          = (IEnumerable <Cart>)list;
            return(Task.CompletedTask);
        }