Ejemplo n.º 1
0
        public void Transfer()
        {
            Console.Clear();
            Console.WriteLine("* Överföring *");
            var accountNumberOne = Validation.InputInt("Från kontonummer: ");
            var accountFrom      = BankSearch.GetCustomerAccountById(_customers, accountNumberOne);

            if (accountFrom == null)
            {
                return;
            }
            var accountNumberTwo = Validation.InputInt("Till kontonummer: ");
            var accountToo       = BankSearch.GetCustomerAccountById(_customers, accountNumberTwo);

            if (accountToo == null)
            {
                return;
            }
            var amount = Validation.InputDecimal("Belopp att överföra? ");

            try
            {
                accountFrom.TransferMoney(accountToo, amount);
            }
            catch (AmountNegativeOrZeroException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (InsufficientFundsException e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public void Withdraw()
        {
            Console.Clear();
            Console.WriteLine("* Uttag *");
            var input           = Validation.InputInt("Kontonummer? ");
            var customerAccount = BankSearch.GetCustomerAccountById(_customers, input);

            if (customerAccount == null)
            {
                return;
            }
            customerAccount.AccountInformation();
            var value = Validation.InputDecimal("Vilket belopp vill du ta ut? ");

            try
            {
                customerAccount.AccountWithdraw(value);
            }
            catch (AmountNegativeOrZeroException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (InsufficientFundsException e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public void AccountProfile()
        {
            Console.Clear();
            Console.WriteLine("* Kontobild *");
            var input           = Validation.InputInt("Kontonummer? ");
            var customerAccount = BankSearch.GetCustomerAccountById(_customers, input);

            if (customerAccount == null)
            {
                return;
            }
            customerAccount.PrintAccountTransactions();
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        public void CreditLimit()
        {
            Console.Clear();
            Console.WriteLine("* Kreditgräns *");
            var input           = Validation.InputInt("Kontonummer? ");
            var customerAccount = BankSearch.GetCustomerAccountById(_customers, input);

            if (customerAccount == null)
            {
                return;
            }
            Console.WriteLine("1) Lägg till/ändra kreditgräns");
            Console.WriteLine("2) Ta bort kreditgräns");
            var select = Console.ReadKey();

            Console.WriteLine();
            try
            {
                switch (select.Key)
                {
                case ConsoleKey.D1:
                    var creditLimit = Validation.InputDecimal("Ange kreditgräns(kr): ");
                    customerAccount.AddCreditLimit(creditLimit);
                    var rate = Validation.InputDecimal("Ange skuldränta(%): ");
                    customerAccount.AddInterestPayable(rate);
                    Console.WriteLine($"En kreditgräns på {creditLimit:C} är adderad till kontot.");
                    Console.WriteLine($"Skuldräntan är satt till {rate}%");
                    break;

                case ConsoleKey.D2:
                    customerAccount.RemoveCreditLimit();
                    break;
                }
            }
            catch (AmountNegativeOrZeroException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }
Ejemplo n.º 5
0
        public void SavingsRate()
        {
            Console.Clear();
            Console.WriteLine("* Sparränta *");
            var input           = Validation.InputInt("Kontonummer? ");
            var customerAccount = BankSearch.GetCustomerAccountById(_customers, input);

            if (customerAccount == null)
            {
                return;
            }
            Console.WriteLine("1) Lägg till/ändra sparränta ");
            Console.WriteLine("2) Ta bort sparränta ");
            var select = Console.ReadKey();

            Console.WriteLine();
            try
            {
                switch (select.Key)
                {
                case ConsoleKey.D1:
                    var rate = Validation.InputDecimal("Ange sparränta(%): ");
                    customerAccount.AddSavingsRate(rate);
                    Console.WriteLine($"Sparränta {rate}% är adderad till kontot.");
                    break;

                case ConsoleKey.D2:
                    customerAccount.RemoveSavingsRate();
                    Console.WriteLine($"Sparräntan för konto #{input} är borttagen.");
                    break;
                }
            }
            catch (AmountNegativeOrZeroException e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }
Ejemplo n.º 6
0
        public void Deposit()
        {
            Console.Clear();
            Console.WriteLine("* Insättning *");
            var input           = Validation.InputInt("Kontonummer? ");
            var customerAccount = BankSearch.GetCustomerAccountById(_customers, input);

            if (customerAccount == null)
            {
                return;
            }
            var value = Validation.InputDecimal("Hur mycket pengar vill du sätta in? ");

            try
            {
                customerAccount.AccountDeposit(value);
            }
            catch (AmountNegativeOrZeroException e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }