Example #1
0
        private async Task <Guid> JoinUserAsync(JoinModel model, string type)
        {
            var localHash    = _cryptoProvider.GetRandomSaltString();
            var passwordHash = _cryptoProvider.GetPasswordHash(model.PasswordString, localHash);

            User user = new User
            {
                UserId       = Guid.NewGuid(),
                Email        = model.Email,
                Phone        = model.Phone,
                LocalHash    = localHash,
                PasswordHash = passwordHash,
                LastName     = model.LastName,
                FirstName    = model.FirstName,
                Role         = _db.Roles.FirstOrDefault(x => x.Name == type.ToUpper())
            };

            var tt = user;

            _db.Users.Add(user);
            await _db.SaveChangesAsync();

            return(user.UserId);
        }