Exemplo n.º 1
0
        public Order Add(Product addition)
        {
            var orderAddition = Container.NewTransientInstance<OrderAddition>();
            orderAddition.Order = this;
            orderAddition.Product = addition;
            Container.Persist(ref orderAddition);
            Price += orderAddition.Product.Price;
            Additions.Add(orderAddition);

            return this;
        }
Exemplo n.º 2
0
 public Order PlaceOrder(Product drink, string customerName)
 {
     var order = Container.NewTransientInstance<Order>();
     order.CustomerName = customerName;
     order.CustomerState = (byte) OrderCustomerStateEnum.Placed;
     order.BaristaState = (byte) OrderBaristaStateEnum.InQueue;
     order.Drink = drink;
     order.Price = drink.Price;
     order.PlacedOn = DateTime.Now;
     Container.Persist(ref order);
     return order;
 }
Exemplo n.º 3
0
 public Boolean HideAdd(Product addition)
 {
     return !IsCustomerState(OrderCustomerStateEnum.Placed);
 }
Exemplo n.º 4
0
 public Product DefaultRemove(Product addition)
 {
     return Choices0Remove().FirstOrDefault();
 }
Exemplo n.º 5
0
 public Product DefaultAdd(Product addition)
 {
     return Choices0Add().FirstOrDefault();
 }
Exemplo n.º 6
0
 public string ValidateRemove(Product addition)
 {
     var orderAddition = Additions.FirstOrDefault(a => a.Product == addition);
     return orderAddition == null ? "No such addition" : null;
 }
Exemplo n.º 7
0
 public string ValidateAdd(Product addition)
 {
     return addition.Addition ? null : "Not an addition";
 }
Exemplo n.º 8
0
        public Order Remove(Product addition)
        {
            var orderAddition = Additions.FirstOrDefault(a => a.Product == addition);
            if (orderAddition == null) return this;
            Price -= orderAddition.Product.Price;
            Container.DisposeInstance(orderAddition);
            Additions.Remove(orderAddition);

            return this;
        }
Exemplo n.º 9
0
 public string ValidatePlaceOrder(Product drink)
 {
     return drink != null ? null : "No such drink";
 }