Exemple #1
0
        static void Main(string[] args)
        {
            ReadifyBank Bank = new ReadifyBank();
            //Just some sample accounts
            List <Account> SeedAcc = new List <Account> {
                new Account("SV-100000", 5000, "PARAS", DateTimeOffset.Now.AddMonths(-1)),
                new Account("SV-200000", 23000, "JAMES", DateTimeOffset.Now.AddMonths(-25)),
                new Account("LN-100000", 10000, "BEN", DateTimeOffset.Now.AddYears(-1)),
                new Account("LN-100000", 50000, "SAHIL", DateTimeOffset.Now.AddYears(-3))
            };

            foreach (Account a in SeedAcc)
            {
                Bank.AccountList.Add(a);
            }
            var end = false;

            while (!end)
            {
                //I have not yet created a database so please enter some accounts info when you start.
                Console.WriteLine("Welcome to ReadifyBank");
                Console.WriteLine(new string('-', 35));
                Console.WriteLine("Select an option \n1) Open Home Loan Account \n2) Open Savings Account \n3) Existing account \n4) Exit");
                Console.WriteLine(new string('-', 35));
                int Choice = 0;
                int.TryParse(Console.ReadLine(), out Choice);
                Console.Clear();
                switch (Choice)
                {
                case 1:
                {
                    Console.WriteLine("Enter Customer Name");
                    var Name = Console.ReadLine();
                    var Date = DateTimeOffset.Now;
                    var acc  = Bank.OpenHomeLoanAccount(Name, Date);
                    Console.WriteLine("Account successfully opened");
                    DisplayAccount(acc);
                }
                break;

                case 2:
                {
                    Console.WriteLine("Enter Customer Name");
                    var Name = Console.ReadLine();
                    var Date = DateTimeOffset.Now;
                    var acc  = Bank.OpenSavingsAccount(Name, Date);
                    Console.WriteLine("Account successfully opened");
                    DisplayAccount(acc);
                }
                break;

                case 3:
                {
                    // I have kept it simple currently so you have to enter the full account number like LN-000001
                    Console.WriteLine("Enter account number");
                    string AccNum = Console.ReadLine();
                    if (Bank.AccountList.Where(a => a.AccountNumber == AccNum).Any())
                    {
                        AccountOptions(AccNum, Bank);
                    }
                    else
                    {
                        Console.WriteLine("Account Number \"{0}\" could not be found", AccNum);
                    }
                }
                break;

                case 4:
                    end = true;
                    break;
                }
            }
        }