public async Task <IActionResult> Register(UserForRegisterDto userForRegisterDto) { // validate request userForRegisterDto.Username = userForRegisterDto.Username.ToLower(); if (await _authBL.UserExists(userForRegisterDto.Username)) { return(BadRequest("Username already exists")); } var userToCreate = new User { Username = userForRegisterDto.Username }; var createdUser = await _authBL.Register(userToCreate, userForRegisterDto.Password); return(StatusCode(201)); }
async Task <bool> UserExist(string username) { return(!await _authBl.UserExists(username)); }