public IOrder CreateOrder( IShoppingCart cart ) { var result = new Order { Id = Guid.NewGuid() }; using( var context = new Context() ) { result.ShoppingCart = context.ShoppingCarts.Single( n => n.Id == cart.Id ); context.Orders.Add( result ); context.SaveChanges(); } return result; }
public IShoppingCart CreateCart( IContact contact ) { var result = new ShoppingCart() { Id = Guid.NewGuid(), Contact = contact as Contact }; using( var context = new Context() ) { context.ShoppingCarts.Add( result ); context.SaveChanges(); } return result; }
public IShoppingCartItem AddItemToCart(ProductOffer productOffer, IShoppingCart cart ) { var result = new ShoppingCartItem { Id = Guid.NewGuid(), Created = System.DateTime.Now }; using( var context = new Context() ) { result.ShoppingCart = context.ShoppingCarts.Single( n => n.Id == cart.Id ); result.ProductOffer = context.ProductOffers.Single( n => n.Id == productOffer.Id ); context.ShoppingCartItems.Add( result ); context.SaveChanges(); } return result; }
public void Product_InsertTest() { //Arrange var product = new Product(); product.Id = Guid.NewGuid(); product.Name = "Crabs"; using( Context context = new Context() ) { context.Products.Add( product ); // var productParames = new AddNewProductParameters { Name = "Horses" }; //var result = context.CallStoredProc<AddNewProductParameters>( context.AddNewProduct, productParames ); context.SaveChanges(); } //Act //Assert }
public static void MyClassInitialize( TestContext testContext ) { _Context = new Context(); TestData.CreateTestData(); }