public virtual void SaveOrder(ShopOrder order) { ISession session = this._sessionManager.OpenSession(); NHibernate.ITransaction tx = session.BeginTransaction(); try { session.SaveOrUpdate(order); tx.Commit(); session.Close(); } catch (Exception ex) { tx.Rollback(); throw new Exception("Unable to save order", ex); } }
protected void lbtnBuy_Click(object sender, EventArgs e) { if (this._module.CurrentShopOrder == null) { ShopOrder order = new ShopOrder(); Cuyahoga.Core.Domain.User currentUser = Context.User.Identity as Cuyahoga.Core.Domain.User; order.Owner = currentUser; order.OrderState = this._module.GetOrderState(1); this._module.SaveOrder(order); this._module.CurrentShopOrder = order; } this._shopProduct = this._module.GetShopProductById(this._module.CurrentShopProductId); ShopOrderLine orderline = new ShopOrderLine(); orderline.Product = this._shopProduct; orderline.ShopOrder = this._module.CurrentShopOrder; this._module.CurrentShopOrder.OrderLines.Add(orderline); this._module.SaveOrder(this._module.CurrentShopOrder); }