Beispiel #1
0
        public void SetUpBank()
        {
            string            check;
            Bank              bankModel  = new Bank();
            MasterBankService masterBank = new MasterBankService();

            Console.WriteLine("\vEnter Bank Name");
            bankModel.Name = InputHandler.GetInput <string>();
            bankModel.Id   = IdGenerator.CreateAccountId(bankModel.Name);
            Console.WriteLine("Generated id: {0}", bankModel.Id);

            Bank bank = banksRepo.Banks.Find(s => s.Id == bankModel.Id);

            Console.WriteLine("\vWant to use default service charge rates (y/n): ");
            if (InputHandler.GetInput <string>() == AppConstants.No)
            {
                Console.WriteLine("Enter service rates for same bank");
                Console.Write("RTGS: ");
                bankModel.RTGSToSameBank = InputHandler.GetInput <decimal>();
                Console.Write("IMPS: ");
                bankModel.IMPSToSameBank = InputHandler.GetInput <decimal>();
                Console.WriteLine("Enter serive rate for other banks");
                Console.Write("RTGS: ");
                bankModel.RTGSToOtherBanks = InputHandler.GetInput <decimal>();
                Console.Write("IMPS: ");
                bankModel.IMPSToOtherBanks = InputHandler.GetInput <decimal>();
                Console.WriteLine("\vEnter default accepted currency for your bank: ");
                bankModel.Currency.Name         = InputHandler.GetInput <string>();
                bankModel.Currency.ExchangeRate = 0;
                List <Currency> currencies = new List <Currency>();
                Console.WriteLine("\vWant to add accepted Currencies and their exchnage rates for you bank : (y/n)");
                check = InputHandler.GetInput <string>();
                while (check == AppConstants.Yes)
                {
                    Console.WriteLine("Enter Currency: ");
                    string currName = InputHandler.GetInput <string>();
                    Console.WriteLine("Enter Excahnge Rate: ");
                    decimal exchangeRate = InputHandler.GetInput <decimal>();
                    currencies.Add(new Currency {
                        Name = currName, ExchangeRate = exchangeRate
                    });
                    Console.WriteLine("\vWant to continue adding accepted Currencies and their exchnage rates for you bank : (y/n)");
                    check = InputHandler.GetInput <string>();
                }
                masterBank.AddBank(banksRepo, bankModel, currencies);
                Console.WriteLine("\vNew Bank set up successful");
            }
            else
            {
                bankModel.RTGSToSameBank   = AppConstants.SameBankRTGS;
                bankModel.IMPSToSameBank   = AppConstants.SameBankIMPS;
                bankModel.RTGSToOtherBanks = AppConstants.OtherBankRTGS;
                bankModel.IMPSToOtherBanks = AppConstants.OtherBankIMPS;

                List <Currency> currencies = new List <Currency>();
                Console.WriteLine("\vWant to add accepted Currencies and their exchnage rates for you bank : (y/n)");
                check = InputHandler.GetInput <string>();
                if (check == AppConstants.Yes)
                {
                    while (check == AppConstants.Yes)
                    {
                        Console.WriteLine("Enter Currency: ");
                        string currName = InputHandler.GetInput <string>();
                        Console.WriteLine("Enter Excahnge Rate: ");
                        decimal exchangeRate = InputHandler.GetInput <decimal>();
                        currencies.Add(new Currency {
                            Name = currName, ExchangeRate = exchangeRate
                        });
                        Console.WriteLine("\vWant to continue adding accepted Currencies and their exchnage rates for you bank : (y/n)");
                        check = InputHandler.GetInput <string>();
                    }
                    Console.WriteLine("\vSelect one of the currrencies as default accepted currency for your bank: ");
                    currencies.ForEach(s => Console.WriteLine("Currency Name: {0}", s.Name));
                    bankModel.Currency.Name = InputHandler.GetInput <string>();
                }
                else
                {
                    currencies.Add(new Currency {
                        Name = AppConstants.BankCurrency, ExchangeRate = 0
                    });
                }
                masterBank.AddBank(banksRepo, bankModel, currencies);
                Console.WriteLine("Please Create User: "******"\vWant to continue creating Users ( y/n ):");
                } while (InputHandler.GetInput <string>() != AppConstants.No);
                Console.WriteLine("\vNew Bank set up successful");
            }
        }