コード例 #1
0
        public OverDraft FindActiveOverdraft(int accountHolderId)
        {
            List <OverDraft> allOverdraft    = FindMultipleOverdraftByAccountHolderId(accountHolderId);
            OverDraft        activeOverdraft = FindActiveOverdraft(allOverdraft);

            return(activeOverdraft);
        }
コード例 #2
0
        public bool checkOverdraftBalance(int accountHolderId, bool printStatus = true)
        {
            List <OverDraft> allOverdrafts = FindMultipleOverdraftByAccountHolderId(accountHolderId);

            if (allOverdrafts == null)
            {
                return(false);
            }

            else
            {
                OverDraft activeOverdraft = FindActiveOverdraft(allOverdrafts);

                if (activeOverdraft == null)
                {
                    return(false);
                }
                else
                {
                    if (printStatus)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine($"You currently have unpaid overdraft of of {activeOverdraft.AmountLeft}");
                    }
                    return(true);
                }
            }
        }
コード例 #3
0
        public void GetOverdraft(AccountHolder account, double amount)
        {
            int       id           = Overdrafts.Count() + 1;
            OverDraft newOverdraft = new OverDraft(id, account, amount);

            account.AccountBalance -= amount;
            Overdrafts.Add(newOverdraft);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"You have successfully gotten an overdraft of {amount}");
        }
コード例 #4
0
        public void PayOverdraft(AccountHolder account, double amount)
        {
            // account.AccountBalance+=amount;
            OverDraft activeOverdraft = FindActiveOverdraft(account.Id);

            if (activeOverdraft != null)
            {
                activeOverdraft.AmountLeft -= amount;

                if (activeOverdraft.AmountLeft <= 0)
                {
                    activeOverdraft.Status = "inactive";
                }
            }
        }
コード例 #5
0
        public OverDraft FindActiveOverdraft(List <OverDraft> multipleOverdraft)
        {
            OverDraft activeOverdraft = multipleOverdraft.Find(i => i.Status == "active");

            return(activeOverdraft);
        }