protected virtual string SetImportedValueText(string oldValue, string newValue, StatementColumnType columnType)
 {
     if (string.IsNullOrWhiteSpace(newValue))
     {
         if (!string.IsNullOrWhiteSpace(oldValue))
         {
             return(oldValue);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(newValue);
     }
 }
        private void SetImportedValueProperty(Transaction.ImportedValues importedValues, StatementColumnType columnType, string columnName, string columnValue)
        {
            switch (columnType)
            {
            case StatementColumnType.Amount:
                importedValues.Amount = this.ParseAmount(columnValue);
                break;

            case StatementColumnType.EntityName:
                importedValues.EntityName = this.SetImportedValueText(importedValues.EntityName, columnValue, columnType);
                break;

            case StatementColumnType.PostedDate:
                importedValues.PostedDate = this.ParsePostednDate(columnValue);
                break;

            case StatementColumnType.TransactionDate:
                importedValues.TransactionDate = this.ParsePostednDate(columnValue);
                break;

            case StatementColumnType.TransactionReason:
                importedValues.TransactionReason = this.ParseTransactionReason(columnValue);
                break;

            case StatementColumnType.InstituteReference:
                importedValues.InstituteReference = this.SetImportedValueText(importedValues.InstituteReference, columnValue, columnType);
                break;

            case StatementColumnType.ProviderCategoryName:
                importedValues.ProviderCategoryName = this.SetImportedValueText(importedValues.ProviderCategoryName, columnValue, columnType);
                break;

            case StatementColumnType.PhoneNumber:
                importedValues.PhoneNumber = this.SetImportedValueText(importedValues.PhoneNumber, columnValue, columnType);
                break;

            case StatementColumnType.Address:
                importedValues.Address = this.SetImportedValueText(importedValues.Address, columnValue, columnType);
                break;

            case StatementColumnType.SubAccountName:
                importedValues.SubAccountName = this.SetImportedValueText(importedValues.SubAccountName, columnValue, columnType);
                break;

            case StatementColumnType.AccountNumber:
                importedValues.AccountNumber = this.SetImportedValueText(importedValues.AccountNumber, columnValue, columnType);
                break;

            case StatementColumnType.CheckReference:
                importedValues.CheckReference = this.SetImportedValueText(importedValues.CheckReference, columnValue, columnType);
                break;

            case StatementColumnType.DebitAmount:
                if (!string.IsNullOrWhiteSpace(columnValue))
                {
                    importedValues.Amount = -1 * this.ParseAmount(columnValue);
                }
                break;

            case StatementColumnType.CreditAmount:
                if (!string.IsNullOrWhiteSpace(columnValue))
                {
                    importedValues.Amount = this.ParseAmount(columnValue);
                }
                break;

            case StatementColumnType.Ignore: break;

            case StatementColumnType.ProviderAttribute:
                if (importedValues.ProviderAttributes == null)
                {
                    importedValues.ProviderAttributes = new Dictionary <string, string>();
                }
                importedValues.ProviderAttributes[columnName] = columnValue;
                break;

            default:
                throw new Exception("Header column  type '{0}' for '{1}' with value '{2}' is not recognized".FormatEx(columnType, columnName, columnValue));
            }
        }