Created
August 28, 2010 08:15
-
-
Save kmckelvin/554889 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public int CreateOrder(Order order) | |
| { | |
| using (var tx = storeDB.Session.BeginTransaction()) | |
| { | |
| var cartItems = GetCartItems(); | |
| //Iterate the items in the cart, adding Order Details for each | |
| foreach (var cartItem in cartItems) | |
| { | |
| var orderDetail = new OrderDetail | |
| { | |
| Album = cartItem.Album, | |
| Order = order, | |
| UnitPrice = cartItem.Album.Price | |
| }; | |
| order.OrderDetails.Add(orderDetail); | |
| } | |
| //Save the order | |
| storeDB.Session.Save(order); | |
| tx.Commit(); | |
| } | |
| //Empty the shopping cart | |
| EmptyCart(); | |
| //Return the OrderId as a confirmation number | |
| return order.OrderId; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment