Example #1
0
        public int InsertNewOrder(Order order, List <OrderDetail> orderDetails)
        {
            int orderId          = 0;
            int isDetailInserted = 0;

            try
            {
                using (var scope = new TransactionScope())
                {
                    order.Id = orderDataAccess.GetMaxOrderId() + 1;
                    orderId  = orderDataAccess.InsertNewOrder(order);
                    if (orderId > 0)
                    {
                        foreach (var orderDetail in orderDetails)
                        {
                            orderDetail.OrderId = orderId;
                            isDetailInserted    = InsertNewOrderDetail(orderDetail);
                        }

                        if (isDetailInserted > 0)
                        {
                            scope.Complete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //
            }

            return(orderId);
        }