public void MakeWithdrawal(decimal amount, string note, DateTime date)
        {
            Account acc = new Account(bankData)
            {
                Name  = userObj.Name,
                AccId = "TXN" + DateTime.Now.ToLongDateString(),
            };

            if (acc.Balance - amount > 0)
            {
                string id         = "TXN" + acc.AccId + DateTime.Now.ToLongDateString();
                var    withdrawal = new Transaction {
                    Amount = -amount,
                    Note   = note,
                    Date   = date,
                    TxnId  = id,
                };
                bankData.AllTransaction.Add(withdrawal);
                Console.Clear();
                Console.WriteLine("Amount withdrawn successfully");
                Console.WriteLine("Current Balance " + acc.Balance.ToString());
                BankApplication bankApp = new BankApplication(bankData);
                bankApp.AccountHolderMenu();
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Not enough balance in the account");
                Console.WriteLine("Current Balance " + acc.Balance.ToString());
                BankApplication bankApp = new BankApplication(bankData);
                bankApp.AccountHolderMenu();
            }
        }
        public void MakeDeposite(decimal amount, string note, DateTime date)
        {
            Account acc = new Account(bankData)
            {
                Name  = userObj.Name,
                AccId = "TXN" + DateTime.Now.ToLongDateString(),
            };

            if (amount > 0)
            {
                string id       = "TXN" + acc.AccId + DateTime.Now.ToLongDateString();
                var    deposite = new Transaction {
                    Amount = amount,
                    Note   = note,
                    Date   = date,
                    TxnId  = id,
                };
                bankData.AllTransaction.Add(deposite);
                Console.Clear();
                Console.WriteLine("Amount deposited successfully");
                Console.WriteLine("Current Balance " + acc.Balance.ToString());
                BankApplication bankApp = new BankApplication(bankData);
                bankApp.AccountHolderMenu();
            }
        }
Esempio n. 3
0
        public void LoginUser(string role)
        {
            Console.WriteLine("Enter your user name");
            string name = Console.ReadLine();

            Console.WriteLine("Enter your password");
            string password  = Console.ReadLine();
            User   loginUser = new User()
            {
                Name     = name,
                Password = password,
                Role     = role == "S" ? "Staff" : "Account Holder",
            };

            BankApplication bankApp = new BankApplication(bankData);

            if (bankData.UserList.Count != 0 && bankData.UserList.Contains(loginUser))
            {
                Console.Clear();
                Console.WriteLine("User successfully logged In");
                if (role == "S")
                {
                    bankApp.BankStaffMenu();
                }
                else
                {
                    bankApp.AccountHolderMenu();
                }
            }
            else
            {
                bankData.UserList.Add(loginUser);
                Console.Clear();
                Console.WriteLine("New User successfully logged In");
                if (role == "S")
                {
                    bankApp.BankStaffMenu();
                }
                else
                {
                    bankApp.AccountHolderMenu();
                }
            }
        }
        public void DisplayTransactions()
        {
            Console.WriteLine("TXN ID \t\t NOTE \t\t AMOUNT \t\t DATE");
            foreach (var transaction in bankData.AllTransaction)
            {
                Console.WriteLine($"{transaction.TxnId} \t\t {transaction.Note} \t\t {transaction.Amount} \t\t {transaction.Date}");
            }
            Console.WriteLine("");
            Console.WriteLine("Enter something to go back");
            String res = Console.ReadLine();

            switch (res)
            {
            default:
                Console.Clear();
                BankApplication bankApp = new BankApplication(bankData);
                bankApp.AccountHolderMenu();
                break;
            }
        }