Example #1
0
        public static async Task Initialize(
            DataProtectionKeysContext dataProtectionKeysContext,
            ApplicationDbContext applicationDbContext,
            IFunctionalSvc functionalSvc,
            ICountrySvc countrySvc)
        {
            await dataProtectionKeysContext.Database.EnsureCreatedAsync();

            await applicationDbContext.Database.EnsureCreatedAsync();

            if (applicationDbContext.ApplicationUsers.Any())
            {
                return;
            }

            // If empty create Admin User and App User
            await functionalSvc.CreateDefaultAdminUser();

            await functionalSvc.CreateDefaultUser();

            // Populate Country database
            var countries = await countrySvc.GetCountriesAsync();

            if (countries.Count > 0)
            {
                await applicationDbContext.Countries.AddRangeAsync(countries);

                await applicationDbContext.SaveChangesAsync();
            }
        }
        public static async Task Initialize(DataProtectionKeysContext dataProtectionKeysContext, ApplicationDbContext applicationDbContext, IFunctionalSvc functionalSvc, ICountrySvc countrySvc)
        {
            // Check, if db DataProtectionKeysContext is created
            // Check, if db ApplicationDbContext is created
            await dataProtectionKeysContext.Database.EnsureCreatedAsync();

            await applicationDbContext.Database.EnsureCreatedAsync();

            // Check, if db contains any users. If db is not empty, then db has been already seeded
            if (applicationDbContext.ApplicationUsers.Any())
            {
                return;
            }

            // If empty create Admin User and App User
            await functionalSvc.CreateDefaultAdminUser();

            await functionalSvc.CreateDefaultUser();

            // Populate Country database
            var countries = await countrySvc.GetCountriesAsync();

            if (countries.Count > 0)
            {
                await applicationDbContext.Countries.AddRangeAsync(countries);

                await applicationDbContext.SaveChangesAsync();
            }
        }
Example #3
0
        public static async Task Initialize(DataProtectionKeysContext dataProtectionKeysContext, ApplicationDbContext applicationDbContext, IFunctionalSvc functionalSvc)
        {
            await dataProtectionKeysContext.Database.EnsureCreatedAsync();

            await applicationDbContext.Database.EnsureCreatedAsync();


            if (applicationDbContext.ApplicationUsers.Any())
            {
                return;
            }

            await functionalSvc.CreateDefaultAdminUser();

            await functionalSvc.CreateDefaultUser();
        }
Example #4
0
        public static async Task InitializeDb(DataProtectionKeyContext dataProtectionKeyContext,
                                              ApplicationDbContext applicationDbContext,
                                              IFunctionalSvc functionalSvc)
        {
            await dataProtectionKeyContext.Database.EnsureCreatedAsync();

            await applicationDbContext.Database.EnsureCreatedAsync();

            // Check, if db contains any users. If db is not empty, then db has been already seeded
            if (applicationDbContext.ApplicationUsers.Any())
            {
                return;
            }

            // If empty create Admin User and App User
            await functionalSvc.CreateDefaultAdminUser();

            await functionalSvc.CreateDefaultUser();
        }
        public static async Task Initialize(DataProtectionKeysContext dataProtectionKeysContext, ApplicationDbContext applicationDbContext, IFunctionalSvc functionalSvc)
        {
            //Check if data protection keys Context is created
            //Check if  ApplicationDbContedxt is created

            await dataProtectionKeysContext.Database.EnsureCreatedAsync();

            await applicationDbContext.Database.EnsureCreatedAsync();

            //check  if db contains any user, If DB is not empty , then DB has been already seeded

            if (applicationDbContext.ApplicationUsers.Any())
            {
                return;
            }


            //If empty create Admin and App user
            await functionalSvc.CreateDefaultAdminUser(); //async add await

            await functionalSvc.CreateDefaultUser();
        }