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); }
public static void Calculate(Order order) { var c = new OrderCalculator(order); c.Calculate(); }