Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            try
            {
                Console.ForegroundColor = ConsoleColor.Cyan;

                var menu = new Menu();
                var bank = new Bank();
                var file = new FileManagement();

                // Get current files
                //file.PrintCurrentDirectory();
                file.GetFiles(bank);

                Console.WriteLine("\n*********************************");
                Console.WriteLine("* Välkommen till kundbilden 2.0 *");
                Console.WriteLine("*********************************\n");

                menu.PrintMenu();
                menu.GetChoiceAndExecute(bank);
            }
            catch (Exception)
            {
                Output.RedColor("Någonting gick helt galet!\nRing supporten på (08-701) 125 80");
            }



            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public void GetChoiceAndExecute(Bank bank)
        {
            try
            {
                var file    = new FileManagement();
                var account = new Account();
                //var trnMgm = new TransactionManagement();

                while (true)
                {
                    Console.Write("\n> ");
                    if (int.TryParse(Console.ReadLine(), out var nr))
                    {
                        switch (nr)
                        {
                        case 0:
                            file.QuitAndSave(bank);
                            break;

                        case 1:
                            Search(bank);
                            break;

                        case 2:
                            ShowCustomer(bank);
                            break;

                        case 3:
                            AddNewCustomer(bank);
                            break;

                        case 4:
                            DeleteCustomer(bank);
                            break;

                        case 5:
                            AddNewAccount(bank);
                            break;

                        case 6:
                            DeleteAccount(bank);
                            break;

                        case 7:
                            CreateContribution(bank, account);
                            break;

                        case 8:
                            CreateWithdrawl(bank);
                            break;

                        case 9:
                            CreateTransfer(bank);
                            break;

                        case 10:
                            PrintTransactions(bank);
                            break;

                        case 11:
                            account.CalculateDailyInterest(bank);
                            PrintStatistics(bank);
                            break;

                        case 12:
                            AmendInterestRate(bank);
                            break;

                        case 13:
                            AmendCreditLimit(bank);
                            break;

                        case 14:
                            AmendCreditInterestRate(bank);
                            break;

                        case 100:
                            Console.Clear();
                            PrintMenu();
                            break;

                        default:
                            Console.WriteLine("Try with a valid number instead!");
                            continue;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Try with numbers instead");
                    }
                }
            }
            catch (IOException)
            {
                Output.RedColor("Problem vid läsning eller sparande till fil. Kontakta admin!");
                GetChoiceAndExecute(bank);
            }
            catch (FormatException)
            {
                Output.RedColor("Problem vid konvertering från text till nummer. Försök igen!");
                GetChoiceAndExecute(bank);
            }
            catch (ArgumentNullException)
            {
                Output.RedColor("Input existerar ej i listan. Försök igen!");
                GetChoiceAndExecute(bank);
            }
            catch (Exception)
            {
                Output.RedColor("Någonting gick fel... Försök igen!");
                GetChoiceAndExecute(bank);
            }
        }