コード例 #1
0
        public async Task <IActionResult> AddUserAsync([FromBody] UserInfo user, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.StringifyModelErrors();
                return(BadRequest(errors));
            }
            if (user == null)
            {
                _logger.LogDebug($"AddUserAsync: failed to create user");
                return(BadRequest("User is null."));
            }

            var result = await _dataRepository.AddUser(user);

            if (result == 0)
            {
                _logger.LogDebug($"failed to create user {user.Email}");
            }
            return(Ok(result));
        }