Example #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();
            }
        }
Example #2
0
 private void ThrowOutOfStockException(OrderProduct orderRow)
 {
     if (orderRow.Count > orderRow.Product.StockBalance)
         throw new OutOfStockException(orderRow.Product.Name, WebStroreResource.OutOfStock);
 }
Example #3
0
        public OrderProduct OrderProductSaveTest()
        {
            Product product = ProductCreateTest();
            var orderProduct = new OrderProduct {
                ProductName = product.Name,
                Product = product,
                Price = product.Price,
                CampaignPrice = 21.0m,
                Count = 1,
                Summa = 22.00m
            };

            Repository.Data.Save(orderProduct);
            Assert.True(product.Id != Guid.Empty);
            return orderProduct;
        }