Esempio n. 1
0
        public void Setup()
        {
            var builder = new DbContextOptionsBuilder <BikesContext>().UseSqlServer(ConnectionString);

            _context = new BikesContext(builder.Options);
            _service = new SalesPersonsService(_context);

            using (var transaction = _context.Database.BeginTransaction())
            {
                _context.SalesPersons.Add(new SalesPerson
                {
                    Id              = 1,
                    FirstName       = "Harecore",
                    LastName        = "Salesman",
                    Address         = "1 Street Ln",
                    Phone           = "321-321-4321",
                    TerminationDate = DateTime.MaxValue,
                    StartDate       = DateTime.MinValue,
                    Manager         = "Joe"
                });

                _context.Database.ExecuteSqlCommand(@"SET IDENTITY_INSERT [SalesPersons] ON");
                _context.SaveChanges();
                _context.Database.ExecuteSqlCommand(@"SET IDENTITY_INSERT [SalesPersons] OFF");
                transaction.Commit();
            }
        }
Esempio n. 2
0
 public SalesPersonsController(SalesPersonsService service)
 {
     _service = service;
 }