Example #1
0
        private void _buildDataForEmployeeService(EmployeesApiDbContext context)
        {
            var nationality = new Nationality("russian");

            _context.Nationalities.Add(nationality);

            _context.AddRange(
                new Employee("tyson", " fury", "01019078123", Clock.Now, nationality.Id),
                new Employee("Deontay", "Wilder", "testPersonalNumber", Clock.Now, nationality.Id)
                );
        }
Example #2
0
        private void _buildDataForLookupService(EmployeesApiDbContext context)
        {
            var countryCode = new CountryCode("+995");

            _context.Add(countryCode);

            var currencyGel = new Currency("gel");
            var currencyUsd = new Currency("usd");

            _context.Currencies.Add(currencyGel);
            _context.Currencies.Add(currencyUsd);

            var nationalityGeo = new Nationality("georgian");
            var nationalityUsa = new Nationality("american");

            _context.Nationalities.Add(nationalityGeo);
            _context.Nationalities.Add(nationalityUsa);// plus one is added in employee service data builder
        }
Example #3
0
        public void MigrateDbContext(IServiceProvider serviceProvider)
        {
            var optionsBuilder = new DbContextOptionsBuilder <EmployeesApiDbContext>();
            var configuration  = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            optionsBuilder.UseSqlServer(configuration.GetConnectionString(EmployeesApiConsts.ConnectionStringName));
            var context = new EmployeesApiDbContext(optionsBuilder.Options);
            var env     = serviceProvider.GetService(typeof(IHostingEnvironment)) as IHostingEnvironment;

            try
            {
                context.Database.Migrate();
                new EmployeesApiContextSeed().SeedAsync(env, context).Wait();
            }
            catch (Exception ex)
            {
            }
        }
Example #4
0
 public TestDataBuilder(EmployeesApiDbContext context)
 {
     _context = context;
 }
Example #5
0
 public EmployeeRepository(IDbContextProvider <EmployeesApiDbContext> dbContextProvider)
     : base(dbContextProvider)
 {
     _dbContext = dbContextProvider.GetDbContext();
 }