public async Task <IActionResult> UpdateUserAsync(int id, [FromBody] UserInfo user, CancellationToken cancellationToken) { if (!ModelState.IsValid) { var errors = ModelState.StringifyModelErrors(); return(BadRequest(errors)); } if (user == null) { _logger.LogDebug($"UpdateUserAsync: failed to update user {id}"); return(BadRequest("User is null.")); } var userToUpdate = await _dataRepository.GetUser(id); if (userToUpdate == null) { return(NotFound("The User record couldn't be found.")); } return(Ok(await _dataRepository.UpdateUser(user, userToUpdate))); }