Ejemplo n.º 1
0
 private static NamedAccount ToNamedAccount(AccountConfig accountConfig)
 {
     return(new NamedAccount(
                new BankAccount
     {
         Swift = new BankAccount.Types.Swift
         {
             Bic = accountConfig.Bic,
             Account = accountConfig.Number
         },
         AccountFeatures = new AccountFeatures
         {
             SupportsPayment = true,
             SupportsReceivePayment = true,
             SupportsSendPayment = true,
             SupportsInformation = true
         }
     },
                accountConfig.Name));
 }
Ejemplo n.º 2
0
        private IList <AccountConfig> AccountsFor(string category)
        {
            return(config.GetSection("accounts:" + category)
                   .GetChildren()
                   .ToList()
                   .Select(x =>
            {
                Address address = new Address();
                var addressConfig = x.GetSection("address");
                if (addressConfig.Value != null)
                {
                    address = new Address
                    {
                        HouseNumber = addressConfig["house"],
                        Street = addressConfig["street"],
                        City = addressConfig["city"],
                        PostCode = addressConfig["post_code"],
                        Country = addressConfig["country"]
                    };
                }
                AccountTransaction transaction = null;

                if (category.Equals("customers"))
                {
                    var transactionConfig = x.GetSection("transaction");
                    TransactionType type = TransactionType.InvalidType;
                    if (transactionConfig["transaction-type"] == "DEBIT")
                    {
                        type = TransactionType.Debit;
                    }
                    else if (transactionConfig["transaction-type"] == "CREDIT")
                    {
                        type = TransactionType.Credit;
                    }
                    transaction = AccountTransaction.NewBuilder(type)
                                  .Amount(Double.Parse(transactionConfig["amount"]), transactionConfig["currency"])
                                  .TransferAmount(Double.Parse(transactionConfig["amount"]), transactionConfig["currency"])
                                  .Description(transactionConfig["description"])
                                  .From(new BankAccount
                    {
                        Swift = new BankAccount.Types.Swift
                        {
                            Bic = x["bic"],
                            Account = x["number"]
                        }
                    })
                                  .To(new BankAccount
                    {
                        Swift = new BankAccount.Types.Swift
                        {
                            Bic = transactionConfig["to:bic"],
                            Account = transactionConfig["to:number"]
                        }
                    })
                                  .Id(transactionConfig["id"])
                                  .ReferenceId(transactionConfig["id"])
                                  .Build();
                }

                double balance = x["balance"] != null
                        ? double.Parse(x["balance"])
                        : 0;

                return AccountConfig.Create(
                    x["name"],
                    address,
                    x["bic"],
                    x["number"],
                    x["currency"],
                    balance,
                    transaction);
            }).ToList());
        }