Exemple #1
0
 public TenantDemoDataBuilder(OrganizationUnitManager organizationUnitManager, UserManager userManager, RandomUserGenerator randomUserGenerator, IBinaryObjectManager binaryObjectManager, IAppFolders appFolders)
 {
     this._organizationUnitManager = organizationUnitManager;
     this._userManager             = userManager;
     this._randomUserGenerator     = randomUserGenerator;
     this._binaryObjectManager     = binaryObjectManager;
     this._appFolders = appFolders;
 }
        public List <User> GetRandomUsers(int userCount, int tenantId)
        {
            List <User>   users = new List <User>();
            List <string> strs  = MyRandomHelper.GenerateRandomizedList <string>(RandomUserGenerator.Names);

            for (int i = 0; i < userCount && i < strs.Count; i++)
            {
                users.Add(RandomUserGenerator.CreateUser(new int?(tenantId), strs[i]));
            }
            return(users);
        }
        private static User CreateUser(int?tenantId, string nameSurname)
        {
            User user = new User()
            {
                TenantId     = tenantId,
                UserName     = RandomUserGenerator.GenerateUsername(nameSurname),
                EmailAddress = RandomUserGenerator.GenerateEmail(nameSurname),
                Password     = (new PasswordHasher()).HashPassword("123456"),
                Name         = nameSurname.Split(new char[] { ' ' })[0],
                Surname      = nameSurname.Split(new char[] { ' ' })[1],
                ShouldChangePasswordOnNextLogin = false,
                IsActive         = RandomHelper.GetRandom(0, 100) < 80,
                IsEmailConfirmed = true
            };

            return(user);
        }
 private static string GenerateEmail(string nameSurname)
 {
     return(string.Concat(RandomUserGenerator.GenerateUsername(nameSurname), "@", RandomHelper.GetRandomOf <string>(RandomUserGenerator.EmailProviders)));
 }