Beispiel #1
0
        public async Task <bool> SaveAsync(IServiceTokenEntity token)
        {
            try
            {
                var pk     = ServiceTokenEntity.GeneratePartitionKey();
                var sToken = await _tableStorage.GetDataAsync(pk, token.RowKey);

                var sNewToken = (ServiceTokenEntity)token;
                if (sToken == null)
                {
                    sToken = new ServiceTokenEntity
                    {
                        PartitionKey = ServiceTokenEntity.GeneratePartitionKey(),
                        RowKey       = token.RowKey,
                        ETag         = token.ETag
                    };
                }
                sToken.SecurityKeyOne = sNewToken.SecurityKeyOne;
                sToken.SecurityKeyTwo = sNewToken.SecurityKeyTwo;
                await _tableStorage.InsertOrMergeAsync(sToken);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public async Task <bool> RemoveAsync(string tokenId)

        {
            try
            {
                var pk = ServiceTokenEntity.GeneratePartitionKey();
                await _tableStorage.DeleteAsync(pk, tokenId);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        public async Task <IServiceTokenEntity> GetAsync(string tokenKey)
        {
            var pk = ServiceTokenEntity.GeneratePartitionKey();

            return(await _tableStorage.GetDataAsync(pk, tokenKey));
        }
Beispiel #4
0
        public async Task <List <IServiceTokenEntity> > GetAllAsync()
        {
            var pk = ServiceTokenEntity.GeneratePartitionKey();

            return((await _tableStorage.GetDataAsync(pk)).Cast <IServiceTokenEntity>().ToList());
        }