Exemplo n.º 1
0
 public Task DeleteAsync(string token, CancellationToken cancellationToken)
 {
     using (var context = new AssetRegisterContext(_databaseUrl))
     {
         AuthenticationTokenEntity foundToken = context.AuthenticationTokens.First(t => t.Token == token);
         context.AuthenticationTokens.Remove(foundToken);
         return(Task.FromResult(context.SaveChanges()));
     }
 }
        public Task <IAsset> CreateAsync(IAsset entity)
        {
            var assetEntity = new AssetEntity(entity);

            using (var context = new AssetRegisterContext(_databaseUrl))
            {
                context.Add(assetEntity);
                context.SaveChanges();
                entity.Id = assetEntity.Id;
                IAsset foundAsset = context.Assets.Find(assetEntity.Id);
                return(Task.FromResult(foundAsset));
            }
        }
Exemplo n.º 3
0
        public Task <IAuthenticationToken> CreateAsync(IAuthenticationToken token, CancellationToken cancellationToken)
        {
            var tokenEntity = new AuthenticationTokenEntity(token);

            using (var context = new AssetRegisterContext(_databaseUrl))
            {
                context.Add(tokenEntity);
                context.SaveChanges();
                token.Id = tokenEntity.Id;
                IAuthenticationToken foundAsset = context.AuthenticationTokens.Find(tokenEntity.Id);
                return(Task.FromResult(foundAsset));
            }
        }