Пример #1
0
        public void CreateOrderDetail(int id)
        {
            var cart  = Session[Constant.CartSession];
            var order = new OrderDao().GetById(id);

            if (order != null)
            {
                if (cart != null)
                {
                    var list = (List <CartItem>)cart;
                    foreach (var item in list)
                    {
                        var orderDetail = new OrderDetail();
                        orderDetail.OrderId   = id;
                        orderDetail.ProductId = item.Product.Id;
                        orderDetail.UnitPrice = item.Product.UnitPrice;
                        orderDetail.Quantity  = item.Quantity;
                        var orderDetailDao = new OrderDetailDao();
                        orderDetailDao.Create(orderDetail);
                    }
                }
            }
            Session[Constant.CartSession] = null;
        }