public void Ship() { if (this.ShippingStatus.Result != ShippingResult.Unshipped) { throw new InvalidOperationException($"Unable to ship an {nameof(Order)} with status {this.ShippingStatus}."); } this.ShippingStatus = new ShippingStatus(Clock.Now, ShippingResult.Shipped); }
public void CancelShipment() { if (this.ShippingStatus.Result != ShippingResult.Unshipped) { throw new InvalidOperationException($"Unable to cancel shipment of an {nameof(Order)} with status {this.ShippingStatus}."); } this.ShippingStatus = new ShippingStatus(Clock.Now, ShippingResult.Cancelled); }
public Order(OrderDescription description) { // Note how the domain constraints are enforced on construction // More specific constraints (such as the contents of OrderDescription) have been enforced on construction of the respective types this.Id = IdGenerator.Current.CreateId(); this.CreationDateTime = Clock.Now; this.Description = description ?? throw new ArgumentNullException(nameof(description)); this.ShippingStatus = new ShippingStatus(this.CreationDateTime, ShippingResult.Unshipped); }