private async Task UpsertBetIfValid(ParticipantBetCommand command, Guid userId)
        {
            GameMetadata gameMetadata = await _gameMetadataCommandRepository.GetAsync(command.GameId);

            if (gameMetadata.StartDate < DateTimeOffset.UtcNow)
            {
                throw new ValidationException("Must no bet for a game which is already running.");
            }

            Bet bet = await _repository.GetByGameIdAndUserIdAsync(command.GameId, userId);

            if (bet != null)
            {
                if (bet.ActualResultPresent)
                {
                    throw new ValidationException("A bet which has an actual result can not be changed anymore.");
                }

                await _repository.UpdateAsync(bet.Id, b => SetValues(b, command, userId));
            }
            else
            {
                await _repository.AddAsync(b => SetValues(b, command, userId));
            }
        }