Beispiel #1
0
        public async Task <GenericResponse <BooleanResponse> > AddUserGame(string shortName, string gameUsername, string gameApiKey,
                                                                           long userId)
        {
            // First check if the game exist
            TGame dbGame = await _gameDataAccess.GetDbGame(shortName);

            if (dbGame == null)
            {
                return(new GenericResponse <BooleanResponse>($"Game {shortName} is not valid", null));
            }

            // Check if the game requires a per-user API key or not
            if (dbGame.ApiKeyRequired && string.IsNullOrWhiteSpace(gameApiKey))
            {
                return(new GenericResponse <BooleanResponse>($"Game {shortName} requires an API key", null));
            }

            // If it's the case then add
            GenericResponse <BooleanResponse> res = await _userGameDataAccess.AddUserGame(dbGame, gameUsername, gameApiKey, userId);

            return(res);
        }