Пример #1
0
        public async Task SeedAsync()
        {
            await _context.Database.MigrateAsync().ConfigureAwait(false);

            if (!await _accountManager.AnyUserAsync(null))
            {
                _logger.LogInformation("Generating inbuilt accounts");

                const string clientRoleName           = "Client";
                const string chiefAuditorRoleName     = "ChiefAutditor";
                const string auditFacilitatorRoleName = "AuditFacilitator";
                const string adminRoleName            = "STPSystemAdmin";
                const string techRoleName             = "STPAMTech";

                await EnsureRoleAsync(adminRoleName, "STPSystemAdmin", ApplicationPermissions.GetAllSTPSystemAdminValues());
                await EnsureRoleAsync(clientRoleName, "Client", ApplicationPermissions.GetClientPermissionValues());
                await EnsureRoleAsync(chiefAuditorRoleName, "ChiefAutditor", ApplicationPermissions.GetChiefAutditorPermissionValues());
                await EnsureRoleAsync(auditFacilitatorRoleName, "AuditFacilitator", ApplicationPermissions.GetAuditFacilitatorPermissionValues());
                await EnsureRoleAsync(techRoleName, "STPAMTech", new string[] { });

                await CreateUserAsync("STPSystemAdmin", "Stp123$", "STP System Admin", "*****@*****.**", "+1 (123) 000-0000", new string[] { adminRoleName });
                await CreateUserAsync("Client", "Stp123$", "Client", "*****@*****.**", "+1 (123) 000-0001", new string[] { clientRoleName });
                await CreateUserAsync("ChiefAutditor", "Stp123$", "Chief Autditor", "*****@*****.**", "+1 (123) 000-0001", new string[] { chiefAuditorRoleName });
                await CreateUserAsync("AuditFacilitator", "Stp123$", "Audit Facilitator", "*****@*****.**", "+1 (123) 000-0001", new string[] { auditFacilitatorRoleName });
                await CreateUserAsync("STPAMTech", "Stp123$", "STP AM / Tech", "*****@*****.**", "+1 (123) 000-0001", new string[] { techRoleName });

                _logger.LogInformation("Inbuilt account generation completed");
            }
        }