/// <summary> /// Seeds the data for the Accounting module. /// </summary> /// <param name="services">The service factory.</param> public static void Seed(IServiceScopeFactory services, IEventsFactory eventsFactory) { using (var scope = services.CreateScope()) { var accountingDb = scope.ServiceProvider.GetRequiredService <AccountingDbContext>(); SeedCompanies(accountingDb, out companies); accountingDb.SaveChanges(); eventsFactory.Raise(new CompanyCreated(companies)); } }
/// <summary> /// Seeds the data for the Projects module. /// </summary> /// <param name="services">The service factory.</param> public static void Seed(IServiceScopeFactory services, IEventsFactory eventsFactory) { using (var scope = services.CreateScope()) { var projectsDb = scope.ServiceProvider.GetRequiredService<ProjectsDbContext>(); // Keep the following methods in this exact order. SeedProjects(projectsDb, out projects); projectsDb.SaveChanges(); eventsFactory.Raise(new ProjectCreated(projects)); } }
/// <summary> /// Seeds the data for the Company module. /// </summary> /// <param name="services">The service factory.</param> public static void Seed(IServiceScopeFactory services, IEventsFactory eventsFactory) { using (var scope = services.CreateScope()) { var companyDb = scope.ServiceProvider.GetRequiredService <CompanyDbContext>(); var accountingDb = scope.ServiceProvider.GetRequiredService <AccountingDbContext>(); // Keep the following methods in this exact order. SeedEmployees(companyDb, out employees); SeedInquiries(companyDb, out inquiries); SeedOffers(companyDb, out offers); companyDb.SaveChanges(); eventsFactory.Raise(new EmployeeCreated(employees)); } }