Order
Class public
Represents an order placed by a Customer, containing one or more OrderItem line items and tracking lifecycle state through OrderStatus.
Definition
Section titled Definitionpublic class OrderRemarks
Section titled RemarksAn Order is always associated with a single customer via
CustomerId. The order progresses through a linear state machine: Pending → Confirmed → Shipped → Delivered. At any point before shipping, the order can transition to Cancelled. The TotalPrice property is computed from the sum of each line item's quantity multiplied by its unit price. It is not persisted and is recalculated on every access.Properties6
Section titled PropertiesCustomerId Section titled CustomerId Guid Guid Order.CustomerIdGets or sets the identifier of the Customer who placed this order.
Remarks
This is a foreign key reference. The referenced customer must exist and be active at the time the order is created.
List<OrderItem> Order.ItemsGets or sets the collection of line items that make up this order.
Remarks
An order must contain at least one item to be valid. Each item captures a product name, quantity, and unit price at the time of purchase.
OrderDate Section titled OrderDate DateTimeOffset DateTimeOffset Order.OrderDateGets or sets the UTC date and time when the order was placed.
Status Section titled Status OrderStatus Order.StatusGets or sets the current lifecycle status of the order.
Remarks
Defaults to
Pending. State transitions should be performed through the order processing pipeline, which validates that each transition is legal and raises the corresponding event via IOrderNotificationService.TotalPrice Section titled TotalPrice decimal decimal Order.TotalPriceGets the total price of the order, computed as the sum of each item's Quantity multiplied by its UnitPrice.
Remarks
This is a calculated property and is not stored. It reflects the current state of the
Items collection.Examples
Section titled ExamplesCreating an order with two line items:
var order = new Order{ Id = Guid.NewGuid(), CustomerId = customer.Id, Items = [ new OrderItem { ProductName = "Widget", Quantity = 3, UnitPrice = 9.99m }, new OrderItem { ProductName = "Gadget", Quantity = 1, UnitPrice = 24.95m } ]};// order.TotalPrice == 54.92m