Exemple #1
0
        public void ProcessInput(SupportBank bank)
        {
            Console.WriteLine("Please enter your query below:");
            string input;

            input = Console.ReadLine();
            while (ShouldContinueProcessingInput(input))
            {
                input = input.Trim();
                if (input.StartsWith(ListCommand))
                {
                    ParseListCommand(input, bank);
                }
                else if (input.StartsWith(ImportCommand))
                {
                    ParseImport(input, bank);
                }
                else
                {
                    PrintHelpMessage();
                }

                input = Console.ReadLine();
            }
        }
Exemple #2
0
        private void ParseListCommand(string input, SupportBank bank)
        {
            string query = input.Substring(ListCommand.Length);

            if (query.Equals("All"))
            {
                bank.WriteAllAccounts();
                logger.Info("User has requested list of all Accounts.");
            }
            else
            {
                bank.WriteTransactionsForAccount(query);
                logger.Info("User has requested list of transactions for account: " + query);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Program.SetupLogger();
            logger.Info("SupportBank program started");

            //string transactions2013 = "C:/Work/Training/SupportBank/Transactions/Transactions2013.json";
            //string transactions2014 = "C:/Work/Training/SupportBank/Transactions/Transactions2014.csv";
            //string transactions2015 = "C:/Work/Training/SupportBank/Transactions/DodgyTransactions2015.csv";
            SupportBank bank = new SupportBank();
            //bank.UpdateRecords(transactions2013);
            //bank.UpdateRecords(transactions2014);
            //bank.UpdateRecords(transactions2015);

            SupportBankConsoleParser consoleParser = new SupportBankConsoleParser();

            consoleParser.ProcessInput(bank);

            logger.Info("SupportBank program shutting down.");
        }
Exemple #4
0
        private void ParseImport(string input, SupportBank bank)
        {
            string path = input.Substring(ImportCommand.Length);

            try
            {
                bank.UpdateRecords(path);
                Console.WriteLine("Records updated successfully!");
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
                logger.Warn("User attempted to load invalid file: '" + path + "'.");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Cannot find a valid file at: '" + path + "'.");
                logger.Warn("User attempted to load invalid file: '" + path + "'.");
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            SupportBank s = new SupportBank();

            s.Run();
        }