Exemple #1
0
 private static void DisplayNameAndBalance(Banking banking)
 {
     foreach (var account in banking.accounts)
     {
         Console.WriteLine("Name:" + account.Name + ", Account Balance:" + account.Balance);
     }
 }
Exemple #2
0
        static void Main(string[] args)
        {
            try
            {
                var config = new LoggingConfiguration();
                var target = new FileTarget {
                    FileName = @"C:\Work\Logs\SupportBank.log", Layout = @"${longdate} ${level} - ${logger}: ${message}"
                };
                config.AddTarget("File Logger", target);
                config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, target));
                LogManager.Configuration = config;

                var parser  = new Parser();
                var banking = new Banking();

                string path         = @"C:\Work\Training\Support_Bank\DodgyTransactions2015.csv";
                var    transactions = parser.ParseCsvFile(path);
                banking.UpdateBalances(transactions);
                while (true)
                {
                    var input = GetUserInput();
                    if (input.Type == CommandType.ListAll)
                    {
                        DisplayNameAndBalance(banking);
                    }
                    else if (input.Type == CommandType.ListSingle)
                    {
                        DisplayDateReasonAndAmount(transactions, input);
                    }
                    else
                    {
                        Console.WriteLine("Input was invalid");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The program encountered a fatal error and needs to close");
                Console.WriteLine(e.Message);
                var logger = LogManager.GetLogger("SupportBank");
                logger.Fatal(e.Message);
            }
        }