コード例 #1
0
ファイル: UserManager.cs プロジェクト: nogalskisam/Fyl
        public async Task<RegistrationResponseDto> RegisterUser(RegistrationRequestDto dto)
        {
            var response = new RegistrationResponseDto()
            {
                EmailExists = await _userRepository.EmailExists(dto.EmailAddress) // check user repository
            };

            if (!response.EmailExists)
            {
                var authentication = _passwordHasher.HashPassword(dto.Password);

                try
                {
                    if (dto.IsLandlord)
                    {
                        _landlordRepository.Register(dto, authentication);
                    }
                    else
                    {
                        _tenantRepository.Register(dto, authentication);
                    }
                    response.Success = true;
                }
                catch (Exception)
                {
                    response.Success = false;
                }
            }

            return response;
        }
コード例 #2
0
ファイル: TenantRepository.cs プロジェクト: nogalskisam/Fyl
        public UserDto Register(RegistrationRequestDto dto, SaltedHashResult auth)
        {
            var tenant = new Tenant()
            {
                TenantUser = new User()
                {
                    EmailAddress = dto.EmailAddress,
                    FirstName = dto.FirstName,
                    LastName = dto.LastName,
                    DateOfBirth = dto.DateOfBirth,
                    DateRegistered = DateTime.UtcNow,
                    Authentication = new UserAuthentication()
                    {
                        PasswordHash = auth.Hash,
                        PasswordSalt = auth.Salt
                    },
                    Role = dto.Role
                }
            };

            _entities.Tenants.Add(tenant);
            _entities.SaveChanges();

            return tenant.TenantUser.ToDto();
        }
コード例 #3
0
ファイル: UserRepository.cs プロジェクト: nogalskisam/Fyl
        public async Task<UserDto> RegisterUser(RegistrationRequestDto dto, SaltedHashResult auth)
        {
            var user = new User()
            {
                EmailAddress = dto.EmailAddress,
                FirstName = dto.FirstName,
                LastName = dto.LastName,
                DateOfBirth = dto.DateOfBirth,
                DateRegistered = DateTime.UtcNow,
                Authentication = new UserAuthentication()
                {
                    PasswordHash = auth.Hash,
                    PasswordSalt = auth.Salt
                },
                Role = dto.Role
            };

            _entities.Users.Add(user);

            await _entities.SaveChangesAsync();

            return user.ToDto();
        }
コード例 #4
0
        public async Task<RegistrationResponseDto> RegisterUser(RegistrationRequestDto dto)
        {
            var result = await _userManager.RegisterUser(dto);

            return result;
        }