Example #1
0
        public void selectAccount()
        {
            Console.WriteLine("Choose account:");
            List <Account> list = AccountXmlLoader.pullAll();
            int            i    = 1;

            foreach (Account account in list)
            {
                Console.WriteLine($"{i++}: {account}");
            }
            int key = int.Parse(Console.ReadLine());

            try
            {
                if (key <= 0 || key > list.Count)
                {
                    throw new Exception("Wrong input");
                }
                if (list[key - 1] == null)
                {
                    throw new Exception("This account is not available");
                }
                currentAcc = list[key - 1];
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Console.ReadKey();
            }
        }
Example #2
0
        public bool showAll()
        {
            bool           emptyList = false;
            List <Account> list      = AccountXmlLoader.pullAll();

            if (list.Count <= 0)
            {
                emptyList = true;
                Console.WriteLine("Empty list");
            }
            int i = 1;

            foreach (Account account in list)
            {
                Console.WriteLine($"{i++}: {account}");
            }
            Console.ReadKey();
            return(emptyList);
        }
Example #3
0
        public void transact()
        {
            List <Account> list = AccountXmlLoader.pullAll();

            if (!getInfo())
            {
                return;
            }
            int i = 1;

            Console.WriteLine("\n\n");
            foreach (Account account in list)
            {
                Console.WriteLine($"{i++}: {account}");
            }
            if (list.Count <= 0)
            {
                Console.WriteLine("List is empty");
                return;
            }
            int key;

            Console.WriteLine("Set receiver");
            do
            {
                key = int.Parse(Console.ReadLine());
            } while (key > list.Count || key <= 0);

            Account receiver = list[key - 1];

            Console.WriteLine("Money: ");
            double money      = double.Parse(Console.ReadLine());
            string receiverId = receiver.AccountId;
            string senderId   = currentAcc.AccountId;

            Console.WriteLine("Enter purpose: ");
            string   purpose = Console.ReadLine();
            Currency cur;

            Console.WriteLine("Choose currency:\n1:GRIVNA\n2:DOLLAR\n3:EURO");
            switch (int.Parse(Console.ReadLine()))
            {
            case 1: cur = Currency.GRIVNA;
                break;

            case 2: cur = Currency.DOLLAR;
                break;

            case 3: cur = Currency.EURO;
                break;

            default: cur = Currency.DOLLAR;
                break;
            }

            if (currentAcc.GetType() == typeof(DefaultAccount))
            {
                (currentAcc as DefaultAccount).paymentslashtransaction(money, purpose, receiverId, cur);
            }
            if (currentAcc.GetType() == typeof(OverdraftAccount))
            {
                (currentAcc as OverdraftAccount).paymentslashtransaction(money, purpose, receiverId, cur);
            }
            Console.ReadKey();
        }