public GetPlayerNameResponse GetPlayerName(int playerId)
        {
            var response = new GetPlayerNameResponse();

            var connectionString = _settings.TournamentDB;

            using (var dataStore = new DataStore(new SqlConnection(connectionString)))
            {
                try
                {
                    if (playerId != null)
                    {
                        response.PlayerName = dataStore.GetPlayerNameFromId(playerId);
                    }
                    else
                    {
                        response.HasErrors = true;
                        response.Errors.Add("Could not get ID from API Get call");
                    }
                }
                catch (Exception e)
                {
                    AddErrorToResponse(response, e.Message);
                }
            }
            return(response);
        }
Exemplo n.º 2
0
    void ReaderHandlerGetPlayerName(string text, string _userId, SqlGetPlayerNameCallback callback)
    {
        GetPlayerNameCommandLog command = GetPlayerNameCommandLog.none;

        string[] lines = text.Split('|');

        GetPlayerNameResponse getPlayerNameResponse = new GetPlayerNameResponse();

        if (GetPlayerNameCommandLog.TryParse(lines[0].Substring(0, lines[0].IndexOf(':')), out command))
        {
            getPlayerNameResponse.command = command;
        }

        if (command == GetPlayerNameCommandLog.succes)
        {
            getPlayerNameResponse.userName = lines[1].Substring(lines[1].IndexOf(':'));
            getPlayerNameResponse.userId   = _userId;
        }

        callback(getPlayerNameResponse);
    }