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; }
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(); }
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(); }
public async Task<RegistrationResponseDto> RegisterUser(RegistrationRequestDto dto) { var result = await _userManager.RegisterUser(dto); return result; }