예제 #1
0
        private async Task <LimpingTest> AddDefaultDataForAnalysis(LimpingDbContext context)
        {
            var analysis = new TestAnalysis
            {
                Id              = Guid.NewGuid(),
                Description     = "Something",
                EndValue        = 1.5,
                LimpingSeverity = LimpingSeverityEnum.Medium,
            };
            var appUser = context.AppUsers.Add(new AppUser
            {
                Id           = "1",
                UserName     = "******",
                LimpingTests = new List <LimpingTest>(),
                Email        = "f",
            }).Entity;
            var limpingTest = context.LimpingTests.Add(new LimpingTest
            {
                AppUserId    = appUser.Id,
                Date         = DateTime.Now,
                TestAnalysis = analysis,
                TestData     = "{numbers: [1, 2, 3]}"
            }).Entity;
            await context.LimpingTests.AddAsync(limpingTest);

            await context.SaveChangesAsync();

            context.Entry(limpingTest).State = EntityState.Detached;
            context.Entry(appUser).State     = EntityState.Detached;
            context.Entry(analysis).State    = EntityState.Detached;
            return(limpingTest);
        }
예제 #2
0
 private async Task AddDefaultDataForLimping(LimpingDbContext context)
 {
     context.AppUsers.Add(new AppUser
     {
         Id           = "1",
         UserName     = "******",
         LimpingTests = new List <LimpingTest>(),
         Email        = "f",
     });
     await context.SaveChangesAsync();
 }
예제 #3
0
        public DataMigrationService(LimpingDbContext context, IServiceProvider serviceProvider)
        {
            _context = context;

            // These must be considered immutable, ie. if you want to delete seed data, please add a new one at the end.
            // We could have dates in names similar to EF migrations, but I think it would require more displine than this does.
            AllMigrations = new[]
            {
                typeof(AddDefaultUser),
            }
            .Select(type => serviceProvider.GetRequiredService(type) as BaseDataMigration)
            .ToList();
        }
예제 #4
0
        public DatabaseFixture(LimpingDbContext context, DataMigrationService dataMigrationService)
        {
            _dataMigrationService = dataMigrationService;
            Context = context;

            var database = context.Database;

            _manageDatabase = true;
            if (_manageDatabase)
            {
                database.EnsureDeleted();
            }

            database.EnsureCreated();
        }
예제 #5
0
 public LimpingTestsService(LimpingDbContext context)
 {
     _context = context;
 }
예제 #6
0
 public DatabaseStartup(LimpingDbContext context, IOptions <LimpingConfiguration> configuration, DataMigrationService seedDataService)
 {
     _context         = context;
     _configuration   = configuration;
     _seedDataService = seedDataService;
 }
예제 #7
0
 public AddDefaultUser(LimpingDbContext context)
 {
     _context = context;
 }
예제 #8
0
 public LimpingTestsController(LimpingDbContext context, ILimpingTestsService limpingTestsService)
 {
     _context             = context;
     _limpingTestsService = limpingTestsService;
 }
예제 #9
0
 public UsersController(LimpingDbContext context, IAppUsersService appUsersService)
 {
     _context         = context;
     _appUsersService = appUsersService;
 }
예제 #10
0
 public AnalysisController(LimpingDbContext context, ITestAnalysesService testAnalysesService)
 {
     _context             = context;
     _testAnalysesService = testAnalysesService;
 }
예제 #11
0
 public AppUsersService(LimpingDbContext context)
 {
     _context = context;
 }
예제 #12
0
 public TestAnalysesService(LimpingDbContext context)
 {
     _context = context;
 }