public override void Submit(ref OrderState state) { //business rule: an order must has at least one order item if (!_orderHeader.OrderItems.Any()) { throw new InvalidOperationException("A new order must have at least one item before it can be submitted"); } state = new OrderPending(_orderHeader); }
public abstract void Reject(ref OrderState state);
public abstract void Complete(ref OrderState state);
public abstract void Submit(ref OrderState state);
public override void Submit(ref OrderState state) { throw new InvalidOperationException("A rejected can't be submitted"); }
public override void Reject(ref OrderState state) { throw new InvalidOperationException("This order is already rejected"); }
public override void Complete(ref OrderState state) { throw new InvalidOperationException("A reject order can't be completed"); }
public override void Reject(ref OrderState state) { throw new InvalidOperationException("A completed can't be rejected"); }
public override void Complete(ref OrderState state) { throw new InvalidOperationException("This order is already completed"); }
public override void Reject(ref OrderState state) { throw new InvalidOperationException("Order must be submitted (pending) before it can be rejected"); }
public override void Submit(ref OrderState state) { //NO-OP }
public override void Reject(ref OrderState state) { state = new OrderRejected(_orderHeader); }
public override void Complete(ref OrderState state) { state = new OrderComplete(_orderHeader); }