Ejemplo n.º 1
0
        private async void SeedDummyUsersWithRoles()
        {
            var serviceProvider = _services.BuildServiceProvider();
            var dummyPassword   = "******";
            var dummyUsers      = (await ApplicationUser.GetDummyUserSet()).ToList();
            var dummyRoles      = (await ApplicationRole.GetDummyRoleSet()).ToList();

            foreach (var dummyRole in dummyRoles)
            {
                await EnsureRole(serviceProvider, dummyRole);

                var dummyUsersPerRole = dummyUsers
                                        .Where(record => record.Email.StartsWith(dummyRole.Name, StringComparison.OrdinalIgnoreCase)).ToList();

                foreach (var dummyUserPerRole in dummyUsersPerRole)
                {
                    await EnsureUser(serviceProvider, dummyUserPerRole, dummyRole, dummyPassword);
                }
            }
        }