public void CanPersistOrder() { IRepository repo = new HibernateRepo(); try { repo.BeginTransaction(); Customer customer = repo.First <Customer>(c => c.CustomerId == 1); ISalesTaxCalculator salesCalculator = new SalesTaxCalculator(); Order order = new Order(customer, salesCalculator); order.With(new OrderLine(this.GetProduct(repo, 3), 1)) .With(new OrderLine(this.GetProduct(repo, 4), 12)); repo.Add <Order>(order); repo.SaveChanges(); repo.CommitTransaction(); } catch (Exception ex) { repo.Rollback(); throw ex; } finally { repo.Dispose(); } }
public void CanPersistOrder() { IRepository repo = new HibernateRepo(); try { repo.BeginTransaction(); Customer customer = repo.First<Customer>(c => c.CustomerId == 1); ISalesTaxCalculator salesCalculator = new SalesTaxCalculator(); Order order = new Order(customer, salesCalculator); order.With(new OrderLine(this.GetProduct(repo,3), 1)) .With(new OrderLine(this.GetProduct(repo, 4), 12)); repo.Add<Order>(order); repo.SaveChanges(); repo.CommitTransaction(); } catch (Exception ex) { repo.Rollback(); throw ex; } finally { repo.Dispose(); } }
public void CreateProductCatalogs() { IRepository repo = new HibernateRepo(); _productCatalogs = new List <ProductCatalog>(); _productCatalogs.Add(new ProductCatalog("CLR via C#", new Money(12.49), false, false)); _productCatalogs.Add(new ProductCatalog("Pirates of Cariaben", new Money(14.99), true, false)); try { repo.BeginTransaction(); for (int i = 0; i < _productCatalogs.Count; i++) { repo.Add <ProductCatalog>(_productCatalogs[i]); } repo.SaveChanges(); repo.CommitTransaction(); } catch (Exception ex) { repo.Rollback(); throw ex; } finally { repo.Dispose(); } }
public void CreateProductCatalogs() { IRepository repo = new HibernateRepo(); _productCatalogs = new List<ProductCatalog>(); _productCatalogs.Add(new ProductCatalog("CLR via C#", new Money(12.49), false, false)); _productCatalogs.Add(new ProductCatalog("Pirates of Cariaben", new Money(14.99), true, false)); try { repo.BeginTransaction(); for (int i = 0; i < _productCatalogs.Count; i++) { repo.Add<ProductCatalog>(_productCatalogs[i]); } repo.SaveChanges(); repo.CommitTransaction(); } catch (Exception ex) { repo.Rollback(); throw ex; } finally { repo.Dispose(); } }