Example #1
0
 public void AddOrder(OrderModel order)
 {
     throw new NotImplementedException();
 }
Example #2
0
        public static OrderModel Create(IUserModel userModel, IEnumerable<CartItemModel> cartItems)
        {
            if (userModel.BillingAddress == null)
            {
                throw new ArgumentException("Billing address cannot be empty.");
            }

            var order = new OrderModel
            {
                BillingAddress = userModel.BillingAddress,
                User = userModel
            };

            foreach (var cartItem in cartItems)
            {
                order.Orderlines.Add(OrderlineModel.Create(cartItem));
            }

            order.Status = OrderStatus.Unpaid;
            order.Key = GenerateOrderId();
            order.DateCreated = DateTime.UtcNow;

            order.TotalSpecialPrice =
                cartItems
                    .ToList()
                    .Select(c => c.DealOption.SpecialPrice)
                    .Aggregate(0.0d, (c1, c2) => { return c1 + c2; });

            order.TotalRegularPrice =
                cartItems
                    .ToList()
                    .Select(c => c.DealOption.RegularPrice)
                    .Aggregate(0.0d, (c1, c2) => { return c1 + c2; });

            return order;
        }
Example #3
0
 public void AddOrder(OrderModel order)
 {
     this.orders.Add(order);
 }