Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
        public static async Task Initialize(
            DataProtectionKeysContext dataProtectionKeysContext,
            ApplicationDbContext applicationDbContext,
            IFunctionalSvc functionalSvc,
            ICountrySvc countrySvc
            )
        {
            // Check, if db DatProtectionKeysContext 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();
            }
        }
Exemplo n.º 3
0
 public EmailSvc(IOptions <SendGridOptions> sendGridOptions,
                 IFunctionalSvc functionalSvc,
                 IOptions <SmtpOptions> smtpOptions, IHostingEnvironment hostingEnvironment)
 {
     _sendGridOptions    = sendGridOptions.Value;
     _smtpOptions        = smtpOptions.Value;
     _hostingEnvironment = hostingEnvironment;
     _functionalSvc      = functionalSvc;
 }
Exemplo n.º 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();
        }
Exemplo n.º 6
0
        public static async Task Initialize(ApplicationDbContext applicationDbContext, IFunctionalSvc functionalSvc)
        {
            // Check, if db ApplicationDbContext is created
            await applicationDbContext.Database.EnsureCreatedAsync();

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

            // If empty create Default User
            await applicationDbContext.Users.AddAsync(new User { FirstName = "Tâm", UserName = "******", Password = functionalSvc.GetMd5Hash(MD5.Create(), "12345").Result, UserType = "Admin" });

            await applicationDbContext.Users.AddAsync(new User { FirstName = "Tâm 2", UserName = "******", Password = functionalSvc.GetMd5Hash(MD5.Create(), "123").Result, UserType = "User" });

            await applicationDbContext.SaveChangesAsync();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
        public static async Task Initialize(ApplicationDbContext applicationDbContext, IFunctionalSvc functionalSvc)
        {
            // Check, if db ApplicationDbContext is created
            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
            await functionalSvc.CreateDefaultUser("Administrator");
        }
Exemplo n.º 9
0
 public LoginController(IConfiguration config, ApplicationDbContext db, IFunctionalSvc functionalSvc)
 {
     _config        = config;
     _db            = db;
     _functionalSvc = functionalSvc;
 }