public async Task <IReadOnlyList <string> > ResolveAsync(string merchantId, AssetAvailabilityType type) { IAssetMerchantSettings personalSettings = await _assetMerchantSettingsRepository.GetAsync(merchantId); string personalAllowed; switch (type) { case AssetAvailabilityType.Payment: personalAllowed = personalSettings?.PaymentAssets; break; case AssetAvailabilityType.Settlement: personalAllowed = personalSettings?.SettlementAssets; break; default: throw new Exception("Unexpected asset availability type"); } IEnumerable <string> generalAllowed = (await _assetGeneralSettingsRepository.GetAsync(type)).Select(x => x.AssetId); if (string.IsNullOrEmpty(personalAllowed)) { return(generalAllowed.ToList()); } IEnumerable <string> resolved = personalAllowed.Split(AssetsSeparator).Where(x => generalAllowed.Contains(x)); return(resolved.ToList()); }
public static AssetMerchantSettingsEntity Create(IAssetMerchantSettings src) { return(new AssetMerchantSettingsEntity { PartitionKey = GeneratePartitionKey(src.MerchantId), RowKey = GenerateRowKey(src.MerchantId), MerchantId = src.MerchantId, PaymentAssets = src.PaymentAssets, SettlementAssets = src.SettlementAssets }); }
public async Task <IActionResult> GetAssetMerchantSettings([FromQuery] string merchantId) { if (string.IsNullOrEmpty(merchantId)) { return(BadRequest(ErrorResponse.Create("Merchant id is invalid"))); } try { IAssetMerchantSettings personal = await _assetSettingsService.GetByMerchantAsync(merchantId); return(Ok(Mapper.Map <AssetMerchantSettingsResponse>(personal))); } catch (InvalidRowKeyValueException e) { _log.ErrorWithDetails(e, new { e.Variable, e.Value }); return(NotFound(ErrorResponse.Create("Merchant not found"))); } }