public List <Account> GetListOfAccounts() { // create list object to return var bmAccountList = new List <Account>(); // get assets from db var dbAssetList = _unitOfWork.Assets.GetAllActiveOrderedByName(); foreach (var dbAsset in dbAssetList) { // get asset type from db var dbAssetType = _unitOfWork.AssetTypes.Get(dbAsset.AssetTypeId); if (dbAssetType == null) { return(new List <Account>()); } // add additional information to asset name if (dbAssetType.Id == AssetType.IdForCreditCard) { var dbAssetSetting = _unitOfWork.AssetSettings.GetActive(dbAsset.Id, Core.Models.SettingType.IdForAccountNumber); if (dbAssetSetting != null) { dbAsset.Name = AccountUtility.FormatAccountName(dbAsset.Name, dbAssetType.Id, dbAssetSetting.Value); } } // transfer dto to bm bmAccountList.Add(new Account(dbAsset, dbAssetType)); } return(bmAccountList); }
/* * public AccountTransaction GetTransactionOptions(int? assetId) * { * var intAssetId = DataTypeUtility.GetIntegerFromString(assetId.ToString()); * * // get asset information * var dtoAsset = GetAssetFromDatabase(intAssetId); * if (dtoAsset == null) * { * throw new ArgumentNullException(); * //return new Business.Models.AssetTransaction(); * } * * // asset name with additional information * var formattedAssetName = GetAssetNameWithAccountNumber(dtoAsset); * * // transfer dto to bm * var bmAssetTransaction = new AccountTransaction(dtoAsset, formattedAssetName); * * // get sli * //bmAssetTransaction.AssetSelectList = GetAssetSelectList(intAssetId.ToString()); * //bmAssetTransaction.TransactionTypeSelectList = GetTransactionTypeSelectList(null); * //bmAssetTransaction.TransactionCategorySelectList = GetTransactionCategorySelectList(null); * * // valid asset information * return bmAssetTransaction; * } */ /* * private Core.Models.Asset GetAssetFromDatabase(int assetId) * { * return _unitOfWork.Assets.Get(assetId); * } */ private string GetAssetNameWithAccountNumber(Asset dbAsset) { var dbAssetSetting = _unitOfWork.AssetSettings.GetActive(dbAsset.Id, SettingType.IdForAccountNumber); if (dbAssetSetting == null) { return(dbAsset.Name); } return(AccountUtility.FormatAccountName(dbAsset.Name, dbAsset.AssetTypeId, dbAssetSetting.Value)); }
public void FormatAccountName_WhenProvidedValidInput_ReturnValue_Test() { // Arrange var assetName = "name"; int assetTypeId = 1; var assetSettingValue = "value"; // Act var result = AccountUtility.FormatAccountName(assetName, assetTypeId, assetSettingValue); // Assert Assert.IsInstanceOfType(result, typeof(string), "Result Type"); }
public void FormatAccountName_WhenProvidedValidInputForCreditCard_ReturnValue_Test() { // Arrange var assetName = "name"; int assetTypeId = AccountUtilityObjectMother.AssetTypeIdForCreditCard; var assetSettingValue = "value"; // Act var result = AccountUtility.FormatAccountName(assetName, assetTypeId, assetSettingValue); // Assert Assert.IsInstanceOfType(result, typeof(string), "Result Type"); Assert.AreEqual("name (value)", result, "Result"); }
public string GetAssetIdentificationInformation(Core.Models.Asset dtoAsset) { // validate input if (dtoAsset == null) { return(string.Empty); } // get additional information var dtoAssetSetting = _unitOfWork.AssetSettings.GetAll() .Where(r => r.IsActive) .FirstOrDefault(r => r.AssetId == dtoAsset.Id); if (dtoAssetSetting != null) { return(AccountUtility.FormatAccountName(dtoAsset.Name, dtoAsset.AssetTypeId, dtoAssetSetting.Value)); } // get standard information return(dtoAsset.Name); }