Beispiel #1
0
        public TodoController(EfstoreContext context)
        {
            _context = context;

            if (_context.TodoItems.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                _context.TodoItems.Add(new TodoItem {
                    Name = "Item1"
                });
                _context.SaveChanges();
            }
        }
Beispiel #2
0
        public ProductController(EfstoreContext context)
        {
            _context = context;

            if (_context.prod.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                _context.prod.Add(new Products {
                    name = "Adidas A1", Description = "Test", price = 100, status = "Instock"
                });

                _context.SaveChanges();
            }
        }
Beispiel #3
0
 public int Commit()
 {
     _ctx.SaveChanges();
     return(0);
 }