public static IAsset GetAssetById(int id) { using (AssetRepository repo = new AssetRepository()) { return(repo.GetById(id)); } }
public void ThenTheAssetIsInserted() { _expected.Id = _sut.Insert(_expected); var actual = _sut.GetById(_expected.Id.Value); Assert.IsNotNull(actual); Assert.AreEqual(_expected, actual); }
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); }
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); } }
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); }