public IActionResult CreateAccount(Guid userId, AddAccountDto addAccountDto) { if (!_userRepo.UserExists(userId)) //check if user exist { return(BadRequest($"User with Id {userId} does not exist")); } lock (_lockAccount) { var user = _userRepo.GetEntities(x => x.Id == userId).SingleOrDefaultAsync().Result; var userDto = _mapper.Map <AddUserDto>(user); addAccountDto.UserEntity = userDto; var result = _accountRepo.CreateByDTOAsync(addAccountDto).GetAwaiter().GetResult(); if (result) { _logger.LogInformation($"user {userId} Create account successfully"); return(Ok("Create account successfully")); } } throw new Exception(); }