示例#1
0
        public void SaveOrder()
        {
            var orderModel = HttpContext.Current.Session[WebStroreResource.CART] as OrderModel;
            var user       = WebStoreSecurity.GetLoggedInUser();

            var order = new Litium.Domain.Entities.ECommerce.Order
            {
                CreateDate     = orderModel.CreateDate,
                OrderNumber    = orderModel.OrderNumber,
                Customer       = user,
                OrderState     = State.Created,
                DeliveryMethod = orderModel.DeliveryMethod,
                Description    = orderModel.DeliveryDescription,
                OrderSumma     = orderModel.OrderSumma,
                OrderTotal     = orderModel.OrderTotal
            };

            var products = new List <OrderProduct>();

            foreach (var cartItem in orderModel.OrderRows)
            {
                var orderRow = new OrderProduct();
                orderRow.CopyFromModel(cartItem);
                products.Add(orderRow);
            }

            using (var uow = new UnitOfWork())
            {
                Repository.Data.Save(products);
                order.OrderProducts = products;
                Repository.Data.Save(order);
                uow.Commit();
            }
        }
示例#2
0
        private XElement ConvertToXElement(LOrder order)
        {
            PropertyInfo[] propertyInfos = order.GetType().GetProperties();
            var            xProduct      = new XElement(NodesName.Order);

            foreach (var property in propertyInfos)
            {
                if (!Attribute.IsDefined(property, typeof(LNotSerializable), true))
                {
                    var xElement = new XElement(property.Name)
                    {
                        Value = property.GetNullValue(order)
                    };
                    xProduct.Add(xElement);
                }

                if (property.PropertyType == typeof(Person))
                {
                    var xElement = ConvertToXElement(order.Customer);
                    xProduct.Add(xElement);
                }

                //if (property.PropertyType == typeof(State))
                //{
                //    var xElement = ConvertToXElement(order.OrderState);
                //    xProduct.Add(xElement);
                //}

                if (property.PropertyType == typeof(IList <OrderProduct>))
                {
                    xProduct.Add(ConvertToXElement(order.OrderProducts));
                }
            }

            return(xProduct);
        }
示例#3
0
        public void SaveOrder()
        {
            var orderModel = HttpContext.Current.Session[WebStroreResource.CART] as OrderModel;
            var user = WebStoreSecurity.GetLoggedInUser();

            var order = new Litium.Domain.Entities.ECommerce.Order
            {
                CreateDate = orderModel.CreateDate,
                OrderNumber =  orderModel.OrderNumber,
                Customer = user,
                OrderState = State.Created,
                DeliveryMethod = orderModel.DeliveryMethod,
                Description = orderModel.DeliveryDescription,
                OrderSumma = orderModel.OrderSumma,
                OrderTotal = orderModel.OrderTotal
            };

            var products = new List<OrderProduct>();

            foreach (var cartItem in orderModel.OrderRows)
            {
                var orderRow = new OrderProduct();
                orderRow.CopyFromModel(cartItem);
                products.Add(orderRow);
            }

            using (var uow = new UnitOfWork())
            {
                Repository.Data.Save(products);
                order.OrderProducts = products;
                Repository.Data.Save(order);
                uow.Commit();
            }
        }
示例#4
0
        public Order OrderSaveTest()
        {
            Order order = new Order {
                CreateDate = _createTestDate,
                Customer = CustomerSaveTest(),
                DeliveryMethod = DeliveryMethodSaveTest(),
                OrderState = State.Created,
                OrderSumma = 100.00m,
                PaymentMethod = PaymentMethodSaveTest()
            };

            Repository.Data.Save(order);
            Assert.True(order.Id != Guid.Empty);

            order.OrderProducts.Add(OrderProductSaveTest());
            Assert.True(order.OrderProducts.Count > 0);
            return order;
        }