public ProductRepositoryTests()
        {
            _connection = new SqliteConnection("DataSource=:memory:");
            _connection.Open();

            var options = new DbContextOptionsBuilder <WingtiptoysContext>()
                          .UseSqlite(_connection)
                          .Options;

            _context = new WingtiptoysContext(options);
            _context.Database.EnsureCreated();

            _context.Categories.Add(new Category()
            {
                CategoryId = 1, CategoryName = "N1", Description = "D"
            });
            _context.Categories.Add(new Category()
            {
                CategoryId = 2, CategoryName = "N2", Description = "D"
            });

            _context.Products.Add(new Product()
            {
                CategoryId = 1, ProductName = "ProductName1", Description = "D"
            });
            _context.Products.Add(new Product()
            {
                CategoryId = 1, ProductName = "ProductName2", Description = "D"
            });
            _context.Products.Add(new Product()
            {
                CategoryId = 1, ProductName = "ProductName3", Description = "D"
            });
            _context.Products.Add(new Product()
            {
                CategoryId = 1, ProductName = "ProductName4", Description = "D"
            });
            _context.Products.Add(new Product()
            {
                CategoryId = 1, ProductName = "ProductName5", Description = "D"
            });
            _context.Products.Add(new Product()
            {
                CategoryId = 2, ProductName = "ProductName6", Description = "D"
            });
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        // Commit All Changes

        public void Save()
        {
            context.SaveChanges();
        }
Ejemplo n.º 3
0
 public void Add(Products entity)
 {
     _wingtiptoysContext.Products.Add(entity);
     _wingtiptoysContext.SaveChanges();
 }
 public void Add(OrderDetails entity)
 {
     _wingtiptoysContext.OrderDetails.Add(entity);
     _wingtiptoysContext.SaveChanges();
 }
Ejemplo n.º 5
0
 public void Add(Categories entity)
 {
     _wingtiptoysContext.Categories.Add(entity);
     _wingtiptoysContext.SaveChanges();
 }
Ejemplo n.º 6
0
 public void Add(CartItems entity)
 {
     _wingtiptoysContext.CartItems.Add(entity);
     _wingtiptoysContext.SaveChanges();
 }