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