public void ApplyDiscountCode(Order order, string code)
        {
            var discountCode = _discountCodeQueryService.FindByCode(code);
            var applier      = new DiscountCodeApplier(discountCode);

            AddAdjustment(order, applier.DiscountAdjustment(order.Total));
            OrderCalculator.Calculate(order);
            _orderRepository.Update(order);
        }
        public Order CreateOrder(int userId, List <ShoppingCartItem> shoppingCartItems)
        {
            var user  = _userService.Find(userId);
            var order = new Order
            {
                User        = user,
                OrderStatus = StatusPending(),
                OrderNumber = GenerateOrderNumber()
            };

            foreach (var shoppingCartItem in shoppingCartItems)
            {
                AddProductVariant(order, shoppingCartItem);
            }

            order.Travelers = BuildTravelerList(order);
            OrderCalculator.Calculate(order);
            _orderRepository.Add(order);

            return(order);
        }
示例#3
0
        public static void Calculate(Order order)
        {
            var c = new OrderCalculator(order);

            c.Calculate();
        }
 public static void Calculate(Order order)
 {
     var c = new OrderCalculator(order);
       c.Calculate();
 }