public async Task <List <PersistKeyedData> > SetPersistKeyedData([FromBody] SetDataRequest request)
        {
            List <PersistKeyedData> inserted_data = new List <PersistKeyedData>();
            //update existing
            var lookup = new PersistKeyedDataLookup();

            lookup.gameLookup    = request.gameLookup;
            lookup.profileLookup = request.profileLookup;
            lookup.persistType   = request.persistType;
            lookup.dataIndex     = request.dataIndex;
            lookup.keys          = new List <string>();

            //find keys to be deleted
            foreach (var key in request.keyValueList)
            {
                if (key.Value == null || key.Value.Length == 0)
                {
                    lookup.keys.Add(key.Key);
                }
            }
            await persistKeyedRepository.Delete(lookup);

            lookup.keys.Clear();

            //find existing keys
            foreach (var key in request.keyValueList)
            {
                lookup.keys.Add(key.Key);
            }
            var found_keys = await persistKeyedRepository.Lookup(lookup);

            foreach (var found_key in found_keys)
            {
                found_key.Modified = DateTime.UtcNow;
                found_key.KeyValue = Convert.FromBase64String(request.keyValueList[found_key.KeyName]);
                inserted_data.Add(await persistKeyedRepository.Update(found_key));
                request.keyValueList.Remove(found_key.KeyName);
            }

            //create new
            foreach (var kvData in request.keyValueList)
            {
                var data = new PersistKeyedData();
                data.KeyName     = kvData.Key;
                data.KeyValue    = Convert.FromBase64String(kvData.Value);
                data.Modified    = DateTime.UtcNow;
                data.DataIndex   = request.dataIndex;
                data.PersistType = request.persistType;

                var game    = (await gameRepository.Lookup(request.gameLookup)).FirstOrDefault();
                var profile = (await profileRepository.Lookup(request.profileLookup)).FirstOrDefault();
                data.Gameid    = game.Id;
                data.Profileid = profile.Id;
                inserted_data.Add(await persistKeyedRepository.Create(data));
            }
            return(inserted_data);
        }
        public Task <IEnumerable <PersistKeyedData> > GetPersistKeyedData([FromBody] GetDataRequest request)
        {
            var lookup = new PersistKeyedDataLookup();

            lookup.gameLookup    = request.gameLookup;
            lookup.profileLookup = request.profileLookup;
            lookup.persistType   = request.persistType;
            lookup.dataIndex     = request.dataIndex;
            lookup.keys          = request.keys;
            lookup.modifiedSince = request.modifiedSince;
            return(persistKeyedRepository.Lookup(lookup));
        }