예제 #1
0
파일: Order.cs 프로젝트: GunioRobot/cqrs
        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);
        }