public async Task <IActionResult> Register([FromBody] RegistrationInformation registrationInformation) { if (string.IsNullOrWhiteSpace(registrationInformation.Username)) { return(BadRequest("Username must not be empty")); } if (string.IsNullOrEmpty(registrationInformation.Password)) { return(BadRequest("Password must not be empty")); } if (string.IsNullOrWhiteSpace(registrationInformation.Email)) { return(BadRequest("Email must not be empty")); } var existingUser = await authenticationModule.FindUserAsync(registrationInformation.Username); if (existingUser != null) { return(Conflict($"User '{registrationInformation.Username}' already exists")); } var newUser = UserFactory.Create(registrationInformation); if (!await authenticationModule.CreateUserAsync(newUser)) { return(StatusCode((int)HttpStatusCode.InternalServerError)); } apiEventLogger.Log(LogLevel.Info, $"New user '{newUser.UserName}' added"); return(Ok()); }