public IActionResult Index([FromBody] GetGameListRequest request, string appId)
        {
            string message;

            if (!IsValid(request, out message))
            {
                var errorResponse = new ErrorResponse {
                    Message = message
                };
                _logger.LogError($"{Request.GetUri()} - {JsonConvert.SerializeObject(errorResponse)}");
                return(BadRequest(errorResponse));
            }

            var list = new Dictionary <string, object>();

            foreach (var pair in _dataAccess.GameGetAll(appId, request.UserId))
            {
                // exists - save result in list
                //if (DataSources.DataAccess.StateExists(appId, pair.Key))
                var stateJson = _dataAccess.StateGet(appId, pair.Key);
                if (stateJson != null)
                {
                    dynamic customProperties = null;
                    if (stateJson != string.Empty)
                    {
                        var state = JsonConvert.DeserializeObject <dynamic>(stateJson);
                        customProperties = state.CustomProperties;
                    }

                    var gameListItem = new GameListItem()
                    {
                        ActorNr = int.Parse(pair.Value), Properties = customProperties
                    };

                    list.Add(pair.Key, gameListItem);
                }
                // not exists - delete
                else
                {
                    _dataAccess.GameDelete(appId, request.UserId, pair.Key);
                }
            }

            var getGameListResponse = new GetGameListResponse {
                Data = list
            };

            _logger.LogInformation($"{Request.GetUri()} - {JsonConvert.SerializeObject(getGameListResponse)}");
            return(Ok(getGameListResponse));
        }
        public dynamic Post(GetGameListRequest request, string appId)
        {
            if (log.IsDebugEnabled) log.DebugFormat("{0} - {1}", Request.RequestUri, JsonConvert.SerializeObject(request));

            string message;
            if (!IsValid(request, out message))
            {
                var errorResponse = new ErrorResponse { Message = message };
                if (log.IsDebugEnabled) log.Debug(JsonConvert.SerializeObject(errorResponse));
                return errorResponse;
            }

            var list = new Dictionary<string, object>();

            foreach (var pair in WebApiApplication.DataAccess.GameGetAll(appId, request.UserId))
            {
                // exists - save result in list
                //if (WebApiApplication.DataAccess.StateExists(appId, pair.Key))
                var stateJson = WebApiApplication.DataAccess.StateGet(appId, pair.Key);
                if (stateJson != null)
                {
                    dynamic customProperties = null;
                    if (stateJson != string.Empty)
                    {
                        var state = JsonConvert.DeserializeObject<dynamic>(stateJson);
                        customProperties = state.CustomProperties;
                    }

                    var gameListItem = new GameListItem(){ ActorNr = int.Parse(pair.Value), Properties = customProperties };

                    list.Add(pair.Key, gameListItem);
                }
                // not exists - delete
                else
                {
                    WebApiApplication.DataAccess.GameDelete(appId, request.UserId, pair.Key);
                }
            }

            var getGameListResponse = new GetGameListResponse { Data = list };
            if (log.IsDebugEnabled) log.Debug(JsonConvert.SerializeObject(getGameListResponse));
            return getGameListResponse;
        }
        public dynamic Post(GetGameListRequest request, string appId)
        {
            appId = appId.ToLowerInvariant();

            string message;

            if (!IsValid(request, out message))
            {
                var errorResponse = new ErrorResponse {
                    Message = message
                };
                if (log.IsDebugEnabled)
                {
                    log.Debug(JsonConvert.SerializeObject(errorResponse));
                }
                return(errorResponse);
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("{0} - {1}", Request.RequestUri, JsonConvert.SerializeObject(request));
            }

            var list = new Dictionary <string, object>();

            foreach (var pair in WebApiApplication.DataAccess.GameGetAll(appId, request.UserId))
            {
                // exists - save result in list
                //if (WebApiApplication.DataAccess.StateExists(appId, pair.Key))
                var stateJson = WebApiApplication.DataAccess.StateGet(appId, pair.Key);
                if (stateJson != null)
                {
                    dynamic customProperties = null;
                    if (stateJson != string.Empty)
                    {
                        var state = JsonConvert.DeserializeObject <dynamic>(stateJson);
                        customProperties = state.CustomProperties;
                    }

                    var gameListItem = new GameListItem()
                    {
                        ActorNr = int.Parse(pair.Value), Properties = customProperties
                    };

                    list.Add(pair.Key, gameListItem);
                }
                // not exists - delete
                else
                {
                    WebApiApplication.DataAccess.GameDelete(appId, request.UserId, pair.Key);
                }
            }

            var getGameListResponse = new GetGameListResponse {
                Data = list
            };

            if (log.IsDebugEnabled)
            {
                log.Debug(JsonConvert.SerializeObject(getGameListResponse));
            }
            return(getGameListResponse);
        }