/// <summary> /// Seed DB per tenant /// </summary> /// <param name="tenantName"></param> /// <returns></returns> public async Task SeedAsync(int tenantId, string adminPassword = "******")//string tenantName) { //await _context.Database.EnsureCreatedAsync(); //Apply migrations: tenant DB witll be created, then migrations applied await _context.Database.MigrateAsync().ConfigureAwait(false); using (var transaction = _context.Database.BeginTransaction()) { //1.Create 'predefined roles' in the Tenant DB //Create 'internal' roles with related permissions await EnsureRoleAsync(adminRoleName, "Tenant admin role", tenantId, ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(managerRoleName, "Manager role of the tenant", tenantId, ApplicationPermissions.GetAllPermissionValues()); await EnsureRoleAsync(consultantRoleName, "Consultant role of the tenat", tenantId, ApplicationPermissions.GetConsultantPermissionValues()); await EnsureRoleAsync(supportRoleName, "Support contact role of the tenant", tenantId, new string[] { }); //TODO: 'Support contact' permissions await EnsureRoleAsync(communicationRoleName, "Communication role of the tenant", tenantId, new string[] { }); //TODO: 'Support role' permissions //await EnsureRoleAsync(userRoleName, "'Simple user' role of tenant", tenantId, new string[] { });//TODO: 'Simple user' permissions await EnsureRoleAsync(candidateRoleName, "Candidate - 'external role' of tenant. Candidate not exepted offer yet", tenantId, ApplicationPermissions.GetCandidatePermissionValues()); //TODO: candidate permissions await EnsureRoleAsync(TWRoleName, "TW - temporary worker 'internal role' of tenant", tenantId, new string[] { }); //TODO: TW permissions await EnsureRoleAsync(PLURoleName, "PLU - permanent worker 'interanl role' of tenant", tenantId, new string[] { }); //TODO: PLU permissions await EnsureRoleAsync(contractorRoleName, "Contractor - 'external role' of tenant", tenantId, new string[] { }); //TODO: contractor permissions await EnsureRoleAsync(clientRoleName, "Client - 'external role' of the tenant. Who are looking for workers", tenantId, ApplicationPermissions.GetClientPermissionValues()); //2. Create predefined users //NOTE: test users per role (to test logins under different accounts) await CreateTestUsers(tenantId, adminPassword); transaction.Commit(); } }