Exemple #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;
        }
 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;
 }
Exemple #3
0
 public Boolean HideAdd(Product addition)
 {
     return !IsCustomerState(OrderCustomerStateEnum.Placed);
 }
Exemple #4
0
 public Product DefaultRemove(Product addition)
 {
     return Choices0Remove().FirstOrDefault();
 }
Exemple #5
0
 public Product DefaultAdd(Product addition)
 {
     return Choices0Add().FirstOrDefault();
 }
Exemple #6
0
 public string ValidateRemove(Product addition)
 {
     var orderAddition = Additions.FirstOrDefault(a => a.Product == addition);
     return orderAddition == null ? "No such addition" : null;
 }
Exemple #7
0
 public string ValidateAdd(Product addition)
 {
     return addition.Addition ? null : "Not an addition";
 }
Exemple #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;
        }
 public string ValidatePlaceOrder(Product drink)
 {
     return drink != null ? null : "No such drink";
 }