Exemple #1
0
 public Model.LineItem CreateLineItem(Model.LineItem item)
 {
     _context.LineItems.Add(_mapper.ParseLineItem(item, true));
     _context.SaveChanges();
     _context.ChangeTracker.Clear();
     return(item);
 }
        public Model.Location AddNewLocation(Model.Location loc)
        {
            Entity.StoreFront locToAdd = _context.StoreFronts
                                         .Add(_mapper.ParseStore(loc, true)).Entity;

            _context.SaveChanges();
            _context.ChangeTracker.Clear();
            return(_mapper.ParseStore(locToAdd));
        }
        public Model.Product AddNewProduct(Model.Product product)
        {
            Entity.Product prodToAdd = _context.Products.Add(_mapper.ParseProduct(product, true)).Entity;
            _context.SaveChanges();

            return(_mapper.ParseProduct(prodToAdd));
        }
Exemple #4
0
 private void Seed()
 {
     //Seed our DB with this method
     //example of using block
     using (var context = new Entity.wssdbContext(options))
     {
         //this makes sure that the state of the db gets recreated each time to maintain the modularity of the test
         context.Database.EnsureDeleted();
         context.Database.EnsureCreated();
         context.Customers.AddRange
         (
             new Entity.Customer {
             Id    = 1,
             CName = "Auryn"
         },
             new Entity.Customer {
             Id    = 2,
             CName = "Melix"
         },
             new Entity.Customer {
             Id    = 3,
             CName = "Roaringsheep"
         }
         );
         context.SaveChanges();
     }
 }
 public Model.Customer AddNewCustomer(Model.Customer customer)
 {
     Entity.Customer newCust = _context.Customers.Add(_mapper.ParseCustomer(customer, true)).Entity;
     _context.SaveChanges();
     _context.ChangeTracker.Clear();
     return(_mapper.ParseCustomer(newCust));
 }