コード例 #1
0
ファイル: AccountingDbSeeder.cs プロジェクト: zszqwe/Wilson
        /// <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));
            }
        }
コード例 #2
0
ファイル: ProjectsDbSeeder.cs プロジェクト: zszqwe/Wilson
        /// <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));
            }
        }
コード例 #3
0
ファイル: CompaniesDbSeeder.cs プロジェクト: zszqwe/Wilson
        /// <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));
            }
        }