private async Task <SetClientResponse> GetClientAsync(SetClientParam param, CancellationToken cancellationToken) { var client = await _repository.GetClientAsync(new GetClientParam { Authority = param.Authority, ClientId = param.ClientId }, cancellationToken); if (client == null) { if (param.CreateIfDoesNotExists) { var retVal = CreateClient(param); return(retVal); } else { throw new ClientDoesNotExistsException(param.ClientId); } } return(new SetClientResponse { Client = client }); }