示例#1
0
        public override double GetCost()
        {
            var size = _beverage.GetSize();

            switch (size)
            {
            case CupSize.Small:
                return(_beverage.GetCost() + 0.10);

            case CupSize.Middle:
                return(_beverage.GetCost() + 0.15);

            case CupSize.Big:
                return(_beverage.GetCost() + 0.20);
            }
            throw new ArgumentException(nameof(CupSize));
        }
 public override float GetCost()
 {
     if (Beverage != null)
     {
         return(base.GetCost() + Beverage.GetCost());
     }
     else
     {
         throw null;
     }
 }
        public OrderItem AddOrderItem(OrderItem item)
        {
            Beverage beverage = _ctx.Beverages
                                .Include(b => b.BeverageSales)
                                .ThenInclude(b => b.Sale)
                                .Where(b => b.Id == item.BeverageId)
                                .FirstOrDefault();

            item.Description = beverage.GetDescription();
            item.UnitPrice   = beverage.GetCost();

            _ctx.OrderItems.Add(item);
            _ctx.SaveChanges();

            return(item);
        }
示例#4
0
        public Order CreateOrder(Order order)
        {
            foreach (OrderItem item in order.Items)
            {
                Beverage beverage = _ctx.Beverages
                                    .Include(b => b.BeverageSales)
                                    .ThenInclude(b => b.Sale)
                                    .Where(b => b.Id == item.BeverageId)
                                    .FirstOrDefault();

                item.Description = beverage.GetDescription();
                item.UnitPrice   = beverage.GetCost();
            }

            _ctx.Orders.Add(order);
            _ctx.SaveChanges();

            return(order);
        }
        public override double GetCost()
        {
            double cost = _beverage.GetCost();

            switch (_beverage.Size)
            {
            case BeverageSize.Tall:
                cost += 0.10;
                break;

            case BeverageSize.Grand:
                cost += 0.15;
                break;

            case BeverageSize.Venti:
                cost += 0.20;
                break;
            }

            return(cost);
        }
示例#6
0
文件: Cream.cs 项目: Denizzi/dp
 public override decimal GetCost()
 {
     return(_beverage.GetCost() + 0.75m);
 }
 public override float GetCost()
 {
     return(beverage.GetCost() + cost);
 }
示例#8
0
 public override double GetCost()
 {
     return(_beverage.GetCost() + 0.20);
 }
示例#9
0
 public override double GetCost()
 {
     return(.15 + beverage.GetCost());
 }