public static string BuildGroupKey(ICurrencyService currencyService, string currency) { if (null == currencyService) { throw new ArgumentNullException(nameof(currencyService)); } if (null == currency) { throw new ArgumentNullException(nameof(currency)); } string groupKey; if (currencyService.CheckCapabilities(currency, CurrencyCapabilities.Debit) || currencyService.CheckCapabilities(currency, CurrencyCapabilities.Credit)) { groupKey = "DC"; } else { groupKey = currency; } return(groupKey); }
private Tuple <string, object> ParseCellValue(string value, string columnName) { if (null == value) { return(null); } value = value.Trim(); switch (columnName) { case "PaymentId": { if (!int.TryParse(value, out var paymentId)) { paymentId = _context.Session.SettingsService.AllocateTransferId(); } return(new Tuple <string, object>(paymentId.ToString(), paymentId)); } case "TargetPurse": { if (string.IsNullOrEmpty(value)) { return(null); } value = value.ToUpper(); string currency; try { currency = _currencyService.ObtainCurrencyByAccountNumber(value); } catch (FormatException) { return(null); } var purseCurrency = _currencyService.ObtainCurrencyByAccountNumber(GetAccountNumber()); if (!purseCurrency.Equals(currency)) { return(null); } if (!_currencyService.CheckCapabilities(currency, CurrencyCapabilities.Transfer)) { return(null); } sourcePurseDropDownList.Enabled = false; return(new Tuple <string, object>(value, value)); } case "Amount": { value = value.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); value = value.Replace(",", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); if (!decimal.TryParse(value, out var amount)) { return(null); } return(new Tuple <string, object>(_formattingService.FormatAmount(amount), amount)); } case "Description": { if (string.IsNullOrEmpty(value)) { return(null); } return(new Tuple <string, object>(value, value)); } } return(null); }