예제 #1
0
        public string CreateUser(string userName, string passWord, int role, string email, string address, long phoneNumber, string bankId, Bank bank)
        {
            string accId = IdGenerator.CreateAccountId(userName);

            bank
            .StaffList
            .Add(new Staff {
                Id           = accId,
                Address      = address,
                EmailAddress = email,
                Name         = userName,
                Password     = passWord,
                PhoneNumber  = phoneNumber,
                IsActive     = true,
                StaffRole    = (StaffDesignation)role
            });
            return(AppConstants.Success);
        }
예제 #2
0
        public string CreateUser(string userName, string passWord, string email, string address, long phoneNumber, string bankId, Bank bank)
        {
            string accId = IdGenerator.CreateAccountId(userName);

            bank
            .Accounts
            .Add(new Account {
                Id = accId, Balance = 0, IsActive = true
            });

            Account account = bank
                              .Accounts
                              .Find(s => s.Id == accId);

            account.User.Name         = userName;
            account.User.Password     = passWord;
            account.User.EmailAddress = email;
            account.User.Address      = address;
            account.User.PhoneNumber  = phoneNumber;
            return(AppConstants.Success);
        }
예제 #3
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");
            }
        }
예제 #4
0
        public void CreateUser(string bankID)
        {
            string      bankId, userName;
            UserService userService = new UserService();

            List <int> inputValidateList = new List <int>();

            bankId = bankID;
            Bank bank           = banksRepo.Banks.Find(s => s.Id == bankId);
            int  selectedOption = (int)UserRole.Staff;

            Console.WriteLine("\vSelect User role");
            foreach (var role in Enum.GetNames(typeof(UserRole)))
            {
                Console.WriteLine("{0}. {1}", selectedOption++, role);
            }

            inputValidateList = new List <int> {
                1, 2
            };
            int selectedRolenum = InputHandler.GetInput <int>(inputValidateList);

            switch (selectedRolenum)
            {
            case 1:
                string email, address, password;
                long   phoneNumber;

                Console.WriteLine("\vEnter User Name: ");
                userName = InputHandler.GetInput <string>();
                Console.WriteLine("Enter Password: "******"Enter Email Address: ");
                email = InputHandler.GetInput <string>();
                Console.WriteLine("Enter Phone Number: ");
                phoneNumber = InputHandler.GetInput <long>();
                Console.WriteLine("Enter Residential Address: ");
                address        = InputHandler.GetInput <string>();
                selectedOption = (int)StaffDesignation.Manager;
                Console.WriteLine("Select Staff position");
                foreach (var position in Enum.GetNames(typeof(StaffDesignation)))
                {
                    Console.WriteLine("{0}. {1}", selectedOption++, position);
                }
                inputValidateList = new List <int> {
                    1, 2
                };
                selectedRolenum = InputHandler.GetInput <int>(inputValidateList);

                userService.CreateUser(userName, password, selectedOption, email, address, phoneNumber, bankId, bank);

                Console.WriteLine($"Account Id = {IdGenerator.CreateAccountId(userName)}");
                break;

            case 2:
                Console.WriteLine("\vEnter User Name: ");
                userName = InputHandler.GetInput <string>();
                Console.WriteLine("Enter Password: "******"Enter Email Address: ");
                email = InputHandler.GetInput <string>();
                Console.WriteLine("Enter Phone Number: ");
                phoneNumber = InputHandler.GetInput <long>();
                Console.WriteLine("Enter Residential Address: ");
                address = InputHandler.GetInput <string>();
                userService.CreateUser(userName, password, email, address, phoneNumber, bankId, bank);

                Console.WriteLine(string.Format("Account Id = {0}\n", IdGenerator.CreateAccountId(userName)));
                break;

            default:
                Console.WriteLine("Select between given options");
                break;
            }
        }