public void AuditsInsertedRecords() { Database.SetInitializer(new ECommerceDbInitializer()); var context = new ECommerceDb(); var product = new Product { CategoryId = 1, ProductName = "Test" }; context.Products.Add(product); context.SaveChanges(); Assert.AreEqual(1, context.AuditRecords.Count()); }
public ActionResult Index() { var db = new ECommerceDb(); var products = db.Products.ToList(); using (var transaction = new TransactionScope()) { var product = db.Products.Create(); product.CategoryId = 1; product.ProductName = "Taco"; product.Promotions.Add(new Promotion { DiscountAmount = 5 }); db.Products.Add(product); db.SaveChanges(); } return(View()); }
public BaseRepository() { ecommerceDb = new ECommerceDb(); }