Exemplo n.º 1
0
 public static IAsset GetAssetById(int id)
 {
     using (AssetRepository repo = new AssetRepository())
     {
         return(repo.GetById(id));
     }
 }
Exemplo n.º 2
0
        public void ThenTheAssetIsInserted()
        {
            _expected.Id = _sut.Insert(_expected);
            var actual = _sut.GetById(_expected.Id.Value);

            Assert.IsNotNull(actual);
            Assert.AreEqual(_expected, actual);
        }
Exemplo n.º 3
0
        public async Task <Asset> GetAsset(Guid id)
        {
            var asset = await _repo.GetById(id);

            if (asset == null)
            {
                _logger.LogDebug($"Asset with ID {id} not found.");
                return(null);
            }

            return(asset);
        }
Exemplo n.º 4
0
        public void ThenTheAssetsAreUpdated()
        {
            _expected[0].Tag         = "CRD-X-00003";
            _expected[0].ModifiedBy  = "user3";
            _expected[1].Description = "Modified description";
            _expected[1].ModifiedBy  = "user3";

            _expected.ForEach(_sut.Update);

            foreach (var asset in _expected)
            {
                var actual = _sut.GetById(asset.Id.Value);
                Assert.AreEqual(asset, actual);
            }
        }
Exemplo n.º 5
0
        public async Task <Asset> GetAsset(string id)
        {
            Asset asset;

            try
            {
                asset = await AssetRepository.GetById(id);

                if (asset == null)
                {
                    asset = await BlockchainDataProvider.GetAsset(id);

                    await AssetRepository.Save(asset);
                }
            }
            catch (Exception ex)
            {
                await Log.WriteError(this.GetType().ToString(), "GetAsset", $"asset_id:{id}", ex, DateTime.Now);

                return(null);
            }

            return(asset);
        }