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));
            }
        }
Esempio n. 2
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));
            }
        }