public GameTableDto CreateGameTable(Guid ownerId, string gameTableName, int playersCount, int cardsCount)
        {
            if (string.IsNullOrWhiteSpace(gameTableName))
            {
                throw new ArgumentNullException(nameof(gameTableName));
            }

            if (ownerId == new Guid())
            {
                throw new ArgumentException(nameof(ownerId));
            }

            var player = _playerRepository.GetById(ownerId);

            if (player == null)
            {
                throw new NullReferenceException($"Отсутствует пользователь с id = {ownerId}");
            }

            if (!_createGameTableChecker.CanCreateGameTable(player))
            {
                throw new Exception($"Игрок с Id = {player.Id} не может создать комнату");
            }

            var gameTable = GameTableFactory.Create(player, gameTableName, playersCount, cardsCount);

            _gameTableRepository.Add(gameTable);

            return(new GameTableDto()
            {
                Id = gameTable.Id,
                Name = gameTable.Name,
                Owner = new PlayerDto()
                {
                    Id = gameTable.Owner.Id,
                    Name = gameTable.Owner.Name
                },
                Type = GameTableTypeCalculator.CalculateGameTableType(gameTable),
                Players = gameTable.Players.Select(p => new GameTablePlayerDto()
                {
                    GameTablePlaceNumber = p.GameTablePlaceNumber,
                    Player = new PlayerDto()
                    {
                        Id = p.Player.Id, Name = p.Player.Name
                    }
                }).ToList()
            });
        }
 public IReadOnlyCollection <GameTableDto> GetGameTables(int pageNum, int perPage)
 {
     return(_gameTableRepository.GetGameTables(pageNum, perPage).Select(gt => new GameTableDto()
     {
         Id = gt.Id,
         Name = gt.Name,
         Owner = new PlayerDto()
         {
             Id = gt.Owner.Id, Name = gt.Owner.Name
         },
         Type = GameTableTypeCalculator.CalculateGameTableType(gt),
         Players = gt.Players.Select(p => new GameTablePlayerDto()
         {
             GameTablePlaceNumber = p.GameTablePlaceNumber,
             Player = new PlayerDto()
             {
                 Id = p.Player.Id, Name = p.Player.Name
             }
         }).ToList()
     }).ToList());
 }