Ejemplo n.º 1
0
        public void CreateOrder(Order order)
        {
            using (var context = DbContextFactory.Create())
            {
                var dbOrder = Mapper.Map<Orders.Order, Models.OrderHeader>(order);

                // Hard code the db order here ( for the moment )
                dbOrder.OrderStatusID = 1;

                context.OrderHeaders.Add(dbOrder);

                context.SaveChanges();

                // Map the Id's back
                order.OrderId = dbOrder.OrderHeaderID;
            }
        }
Ejemplo n.º 2
0
        public static Order FromShoppingCart(Cart shoppingCart)
        {
            var orderGuid = Guid.NewGuid();

            // Create new one from shopping cart, ready for Db
            var order = new Order
            {
                GUID = orderGuid,
                ShippingDetails = shoppingCart.ShippingDetails,
                BillingDetails = shoppingCart.BillingDetails,
                HandlingTotal = 0,
                ShippingTotal = shoppingCart.ShippingCost,
                TaxTotal = shoppingCart.CalculateTotalTax(),
                TotalAmount = shoppingCart.CalculateSubTotalWithoutTax(),
                SourceIpAddress = shoppingCart.SourceIpAddress,
                OrderLineItems = shoppingCart.GetItems().Select(OrderLineItem.FromShoppingCartItem).ToArray(),
                UserName = shoppingCart.UserName,
                CreatedDateTime = DateTime.Now,
                PaymentTransactionId = shoppingCart.PaymentTransactionId,
                InvoiceNumber = shoppingCart.InvoiceNumber
            };

            return order;
        }