GetBic

  1. Prerequisite
  2. Synchronous
  3. Asynchronous

1. Prerequisite

To validate an iban code you need to know
  • the iban code as string
That's all you need. :-)

2. Synchronous

To get a BIC for an iban code in synchronous way, you could do something like this:

[...]
//    Include IBAN-Api AVENTUM SOLUTIONS GmbH
using AS.IBAN;
using AS.IBAN.Model;
using AS.IBAN.Helper;
[...]
{
[...]
        private string GetGermanBic(string iban)
        {
            IbanGetBic getBic = new IbanGetBic();
            string bic = string.Empty;

            try
            {
                var result = getBic.GetBic(iban);

                bic = result.Bic;
            }
            catch (IbanException ex)
            {
                //  do some error handling
            }

            return bic;
        }
[...]
}

3. Asynchronous

Following the async-await pattern you can also get a BIC for an IBAN code in asynchronous way. You could do something like this:

[...]
//    Include IBAN-Api AVENTUM SOLUTIONS GmbH
using AS.IBAN;
using AS.IBAN.Model;
using AS.IBAN.Helper;
[...]
{
[...]
        private async Task<string> GetGermanBic(string iban)
        {
            IbanGetBic getBic = new IbanGetBic();
            string bic = string.Empty;

            try
            {
                var result = await getBic.GetBicAsync(iban);

                bic = result.Bic;
            }
            catch (IbanException ex)
            {
                //  do some error handling
            }

            return bic;
        }
[...]
}




Last edited Nov 22, 2013 at 4:33 PM by AventumSolutions, version 3