Exemplo n.º 1
0
        public Order(
            Guid orderId,
            DiningLocation diningLocation,
            OrderItem[] orderItems,
            IProductInfo[] products)
            : this()
        {
            var price = orderItems
                .Select(i => new
                                 {
                                     product = products.Single(p => p.MenuItemId == i.MenuItemId),
                                     item = i
                                 })
                .Select(i => i.item.Quantity*i.product.Price)
                .Sum();

            var e = new OrderPlaced(
                orderId,
                diningLocation,
                orderItems,
                price);
            ApplyChange(e);
        }