Пример #1
0
        private Order OrderWithSingleProductOfPriceAndMaxTotalCost(Money productPrice, Money limit)
        {
            Order order = new Order(OrderLimit.LimitedBy(limit));

            order.AddNewProduct(ProductOfValue(productPrice));
            return(order);
        }
Пример #2
0
        private Money Recalculate()
        {
            var totalCost = Items.Select(x => x.Cost()).Aggregate((x, y) => x.Add(y));
            var discount  = _discountPolicy(this);

            totalCost = totalCost.MultiplyBy(1 - discount);
            if (OrderLimit.IsExceededBy(totalCost))
            {
                throw new OrderMaxTotalCostExceeded();
            }
            return(totalCost);
        }
Пример #3
0
 public Order(OrderLimit limit)
 {
     _discountPolicy = DefaultPolicy();
     Id         = GenerateId();
     OrderLimit = limit;
 }
Пример #4
0
 public Order()
 {
     _discountPolicy = DefaultPolicy();
     Id         = GenerateId();
     OrderLimit = OrderLimit.Unlimited();
 }