示例#1
0
 private void UpdatePrice()
 {
     SubtotalPrice = (float)Math.Round(SelectedSize.SizePrice * Qty + SelectedTopping.Aggregate(
                                           0f, (total, next) => total + PizzaInfo.Topping.Where(d => d.ToppingId == next).FirstOrDefault().ToppingPrice
                                           ) * Qty, 2);
     TaxPrice   = (float)Math.Round(SubtotalPrice * 0.13, 2);
     TotalPrice = (float)Math.Round(SubtotalPrice + TaxPrice, 2);
 }
示例#2
0
        private async Task AddItem()
        {
            UpdatePrice();
            var       items = StateContainer.Items;
            PizzaItem item  = new PizzaItem
            {
                ItemId    = new Guid(),
                Qty       = Qty,
                SizeId    = SelectedSize.SizeId,
                TypeId    = PizzaInfo.Type.Where(o => o.TypeName == PizzaName).FirstOrDefault().TypeId,
                ToppingId = SelectedTopping.ToArray(),
                Subtotal  = SubtotalPrice,
                Tax       = TaxPrice,
                Total     = TotalPrice
            };

            items.Add(item);

            StateContainer.SetItems(items);
        }