Пример #1
0
        public void CommitLoan(ILoan loan)
        {
            var newId = this.LoanList.Count == 0 ? 1 : this.LoanList.Max(l => l.ID) + 1;

            loan.Commit(newId);

            this.LoanList.Add(loan);
        }
Пример #2
0
        public void CommitLoan(ILoan loan)
        {
            if (loan == null)
                throw new ArgumentException("Error: loan can\'t be null.");

            loan.Commit(_loans.Count);
            _loans.Add(loan);
        }
Пример #3
0
        public void Borrow(ILoan loan)
        {
            if(this.State != BookState.AVAILABLE) throw new InvalidOperationException("Cannot borrow a book that is not available");

            this.Loan = loan;

            this.State = BookState.ON_LOAN;
        }
Пример #4
0
        public void Borrow(ILoan loan)
        {
            if (loan == null)
                throw new ArgumentException("Error loan cant be null.");

            if (_state != BookState.AVAILABLE)
                throw new ApplicationException($"Error: Guard against wrong state : {_state}");

            _loan = loan;

            _state = BookState.ON_LOAN;
        }
Пример #5
0
 public Book(string author, string title, string callNumber, int bookID)
 {
     if (!sane(author, title, callNumber, bookID))
     {
         throw new ArgumentException("Member: constructor : bad parameters");
     }
     this.author = author;
     this.title = title;
     this.callNumber = callNumber;
     this.id = bookID;
     this.state = BookConstants.BookState.AVAILABLE;
     this.loan = null;
 }
Пример #6
0
 public void Borrow(ILoan loan)
 {
     if (loan == null)
     {
         throw new ArgumentException("Book: borrow : Bad parameter: loan cannot be null");
     }
     if (!(state == BookConstants.BookState.AVAILABLE))
     {
         string mesg = String.Format("Illegal operation in state : {0}", state);
         throw new ApplicationException(mesg);
     }
     this.loan = loan;
     state = BookConstants.BookState.ON_LOAN;
 }
Пример #7
0
 public void CommitLoan(ILoan loan)
 {
     if (loan == null)
     {
         throw new ArgumentException(
             String.Format("LoanDAO : commitLoans : loan cannot be null."));
     }
     IMember borrower = loan.Borrower;
     borrower.AddLoan(loan);
     IBook book = loan.Book;
     book.Borrow(loan);
     loan.Commit();
     int id = loan.ID;
     loanDict.Add(id, loan);
 }
Пример #8
0
 public void AddLoan(ILoan loan)
 {
     if (loan == null)
     {
         throw new ArgumentException("Member: AddLoan : loan cannot be null");
     }
     if (!BorrowingAllowed)
     {
         string mesg = String.Format("Member: AddLoan : illegal operation in state: {0}", state);
         throw new ApplicationException(mesg);
     }
     loanList.Add(loan);
     updateState();
 }
Пример #9
0
 public BNB(IBank bank, ILoan loan, ICredit credit)
 {
     _bank   = bank;
     _loan   = loan;
     _credit = credit;
 }
Пример #10
0
 public LoanService(IGeneric <Loan> genericRepository, ILoan loan) : base(genericRepository)
 {
     _genericRepository = genericRepository;
     _loan = loan;
 }
Пример #11
0
 public void Update(ILoan loan)
 {
 }
Пример #12
0
 public void ReturnBook(bool damaged)
 {
     if (!(state == BookConstants.BookState.ON_LOAN || state == BookConstants.BookState.LOST))
     {
         throw new ApplicationException(String.Format("Illegal operation in state : {0}", state));
     }
     loan = null;
     if (damaged)
     {
         state = BookConstants.BookState.DAMAGED;
     }
     else
     {
         state = BookConstants.BookState.AVAILABLE;
     }
 }
Пример #13
0
 public BankAccount(ILoan loan)
 {
     _loan = loan;
 }
Пример #14
0
 public ActionResult <LoanSchedule> GetAppInfo([FromBody] ILoan loan)
 {
     return(Ok(loan.CreateLoanSchedule()));
 }
Пример #15
0
 public ClientService(IGeneric <Client> genericRepository, IClient client, ILoan loan) : base(genericRepository)
 {
     _genericRepository = genericRepository;
     _client            = client;
 }
Пример #16
0
 public Mortgage(IBank bank, ICredit credit, ILoan loan)
 {
     _bank   = bank;
     _credit = credit;
     _loan   = loan;
 }
Пример #17
0
 public BankAccount(int accountNumber, double balance, string type, List <ITransaction> accountTransactions, List <ILoan> accountLoans, ILoan overDraftLoan)
 {
     AccountNumber         = accountNumber;
     Balance               = balance;
     Type                  = type;
     AccountTransactions   = accountTransactions;
     AccountLoans          = accountLoans;
     OverDraftLoan         = overDraftLoan;
     InterestRate          = .02;
     OverDraftInterestRate = .05;
 }
Пример #18
0
        private static void OpenNewAccount(IBankCustomer bankCustomer)
        {
            while (true)
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("   " + bankCustomer.FirstName + " " + bankCustomer.LastName + "\n");
                    Console.WriteLine("==========================================================================================");
                    Console.WriteLine("║                                                                                        ║");
                    Console.WriteLine("║                       PICK AN OPTION FROM THE NEW ACOUNTS MENU                         ║");
                    Console.WriteLine("║                                                                                        ║");
                    Console.WriteLine("==========================================================================================\n");
                    Console.WriteLine("1) Open Checking Account  2) Open Business Account 3) Request Loan  4) Open Term Deposit 5) back  6) Logout\n\n");
                    Console.Write("Enter:");
                    int option = Convert.ToInt32(Console.ReadLine());
                    if (option == 1)
                    {
                        IAccount account = AdministrativeOperations.OpenAccount(bankCustomer, "Checking Account");
                        if (account != null)
                        {
                            Console.WriteLine("CHECKING ACCOUNT WITH ACCOUNT NUMBER " + account.AccountNumber + " WAS SUCCESSFULLY CREATED!\n");
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("CHECKING ACCOUNT CREATION FAILED!!!\n");
                            Console.ForegroundColor = ConsoleColor.Green;
                        }
                        Console.WriteLine("\nPress any key to continue...");
                        Console.ReadKey();
                    }
                    else if (option == 2)
                    {
                        IAccount account = AdministrativeOperations.OpenAccount(bankCustomer, "Business Account");
                        if (account != null)
                        {
                            Console.WriteLine("BUSINESS ACCOUNT WITH ACCOUNT NUMBER " + account.AccountNumber + " WAS SUCCESSFULLY CREATED!\n");
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("BUSINESS ACCOUNT CREATION FAILED!!!\n");
                            Console.ForegroundColor = ConsoleColor.Green;
                        }
                        Console.WriteLine("\nPress any key to continue...");
                        Console.ReadKey();
                    }
                    else if (option == 3)
                    {
                        ILoan loan = null;
                        while (true)
                        {
                            try
                            {
                                Console.Write("1) Personal Loan\n2) Business loan");
                                Console.Write("\n\nEnter Choice:");
                                int value = Convert.ToInt32(Console.ReadLine());
                                Console.Write("\n\nEnter loan amount (must be greater zero):");
                                double amount = Convert.ToDouble(Console.ReadLine());
                                if (value == 1 && amount > 0)
                                {
                                    loan = AdministrativeOperations.RequestLoan(bankCustomer, amount, "personal loan");
                                    break;
                                }
                                else if (value == 2 && amount > 0)
                                {
                                    loan = AdministrativeOperations.RequestLoan(bankCustomer, amount, "business loan");
                                    break;
                                }
                                else
                                {
                                    ErrorHandler();
                                }
                            }
                            catch (Exception e)
                            {
                                CatchHandler(e);
                            }
                        }

                        if (loan != null)
                        {
                            Console.WriteLine("\nLOAN REQUEST FOR $" + loan.Amount + " WAS APPROVED!\nTHE INTEREST RATE ON THE LOAN IS :" + (loan.InterestRate * 100) + "% APR\n");
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("LOAN REQUEST FAILED!!!\n");
                            Console.ForegroundColor = ConsoleColor.Green;
                        }
                        Console.WriteLine("\nPress any key to continue...");
                        Console.ReadKey();
                    }
                    else if (option == 4)
                    {
                        double amount = 0;
                        try
                        {
                            Console.Write("\n\nEnter Term Deposit amount:");
                            amount = Convert.ToDouble(Console.ReadLine());
                        }
                        catch (Exception e)
                        {
                            CatchHandler(e);
                        }
                        ITermDeposit termDeposit = AdministrativeOperations.OpenTermDeposit(bankCustomer, amount);
                        if (termDeposit != null)
                        {
                            Console.WriteLine("\nTERM DEPOSIT OF $" + String.Format("{0:n}", amount) + " WAS APPROVED!\nTHE YIELD ON THE ACCOUNT IS " + (termDeposit.InterestRate * 100) + "% APR\n");
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("TERM DEPOSIT REQUEST FAILED!!!\n");
                            Console.ForegroundColor = ConsoleColor.Green;
                        }
                        Console.WriteLine("\nPress any key to continue...");
                        Console.ReadKey();
                    }
                    else if (option == 5)
                    {
                        break;
                    }
                    else if (option == 6)
                    {
                        Logout();
                    }
                    else
                    {
                        ErrorHandler();
                    }
                }
                catch (Exception e)
                {
                    CatchHandler(e);
                }
            }
        }
Пример #19
0
 public void RemoveLoan(ILoan loan)
 {
     if (loan == null)
     {
         throw new ArgumentException("Member: RemoveLoan : loan cannot be null");
     }
     if (!loanList.Contains(loan))
     {
         throw new ArgumentException("Member: RemoveLoan : loan not present");
     }
     loanList.Remove(loan);
     updateState();
 }
 public LoanRepaymentDetails(ILoan loan)
 {
     this.loan = loan;
 }
Пример #21
0
        public void RemoveLoan(ILoan loan)
        {
            if(loan == null) throw new ArgumentException("Loan cannot be null");

            if(!this.Loans.Contains(loan)) throw new ArgumentException("Loan was not found in member's loans");

            this.Loans.Remove(loan);

            if(!this.HasOverDueLoans && ! this.HasReachedFineLimit) this.State = MemberState.BORROWING_ALLOWED;
        }
Пример #22
0
 public LoanController(ILoan _ILoan, IBook _IBook, IBorrower _IBorrower)
 {
     _Loan     = _ILoan;
     _Book     = _IBook;
     _Borrower = _IBorrower;
 }
 public BookController(IBook book, ICategory category, ILoan loan)
 {
     _book     = book;
     _category = category;
     _loan     = loan;
 }
Пример #24
0
 public MemberController(IMember member, ILoan loan)
 {
     _member = member;
     _loan   = loan;
 }
Пример #25
0
 private void NothingOnLoan()
 {
     _loan = null;
 }
Пример #26
0
 public void Add(ILoan loan)
 {
 }
Пример #27
0
        public void RemoveLoan(ILoan loan)
        {
            if (loan == null)
                throw new ArgumentException("Error: loan is null.");

            if (!_loans.Contains(loan))
                throw new ArgumentException("Error: Loan doesn't exist.");

            _loans.Remove(loan);

            CheckState();
        }
Пример #28
0
 public Amortization(ILoan loan)
 {
     this.loan = loan;
 }
Пример #29
0
        public void AddLoan(ILoan loan)
        {
            if(loan == null) throw new ArgumentException("Loan cannot be null");

            if (this.State == MemberState.BORROWING_DISALLOWED)
                throw new InvalidOperationException("Cannot add a loan when member is not allowed to borrow");

            this.Loans.Add(loan);

            if(this.HasReachedLoanLimit || this.HasReachedFineLimit) this.State = MemberState.BORROWING_DISALLOWED;
        }
Пример #30
0
 public LoansController(ILoan loan, IConfiguration config, IHttpContextAccessor accessor)
 {
     _loan     = loan;
     _config   = config;
     _accessor = accessor;
 }
Пример #31
0
 public BNB()
 {
     _bank   = new Bank();
     _loan   = new Loan();
     _credit = new Credit();
 }
Пример #32
0
        private void SetUpTestData()
        {
            IBook[]   book   = new IBook[15];
            IMember[] member = new IMember[6];

            book[0]  = _bookDAO.AddBook("author1", "title1", "callNo1");
            book[1]  = _bookDAO.AddBook("author1", "title2", "callNo2");
            book[2]  = _bookDAO.AddBook("author1", "title3", "callNo3");
            book[3]  = _bookDAO.AddBook("author1", "title4", "callNo4");
            book[4]  = _bookDAO.AddBook("author2", "title5", "callNo5");
            book[5]  = _bookDAO.AddBook("author2", "title6", "callNo6");
            book[6]  = _bookDAO.AddBook("author2", "title7", "callNo7");
            book[7]  = _bookDAO.AddBook("author2", "title8", "callNo8");
            book[8]  = _bookDAO.AddBook("author3", "title9", "callNo9");
            book[9]  = _bookDAO.AddBook("author3", "title10", "callNo10");
            book[10] = _bookDAO.AddBook("author4", "title11", "callNo11");
            book[11] = _bookDAO.AddBook("author4", "title12", "callNo12");
            book[12] = _bookDAO.AddBook("author5", "title13", "callNo13");
            book[13] = _bookDAO.AddBook("author5", "title14", "callNo14");
            book[14] = _bookDAO.AddBook("author5", "title15", "callNo15");

            member[0] = _memberDAO.AddMember("fName1", "lName1", "0001", "email1");
            member[1] = _memberDAO.AddMember("fName2", "lName2", "0002", "email2");
            member[2] = _memberDAO.AddMember("fName3", "lName3", "0003", "email3");
            member[3] = _memberDAO.AddMember("fName4", "lName4", "0004", "email4");
            member[4] = _memberDAO.AddMember("fName5", "lName5", "0005", "email5");
            member[5] = _memberDAO.AddMember("fName6", "lName6", "0006", "email6");

            DateTime borrowDate = DateTime.Now;
            TimeSpan loanPeriod = new TimeSpan(LoanConstants.LOAN_PERIOD, 0, 0, 0);
            DateTime dueDate    = borrowDate.Add(loanPeriod);

            //create a member with overdue loans
            for (int i = 0; i < 2; i++)
            {
                ILoan loan = _loanDAO.CreateLoan(member[1], book[i], borrowDate, dueDate);
                _loanDAO.CommitLoan(loan);
            }
            DateTime checkDate = dueDate.Add(new TimeSpan(1, 0, 0, 0));

            _loanDAO.UpdateOverDueStatus(checkDate);

            //create a member with maxed out unpaid fines
            member[2].AddFine(10.0f);

            //create a member with maxed out loans
            for (int i = 2; i < 7; i++)
            {
                ILoan loan = _loanDAO.CreateLoan(member[3], book[i], borrowDate, dueDate);
                _loanDAO.CommitLoan(loan);
            }

            //a member with a fine, but not over the limit
            member[4].AddFine(5.0f);

            //a member with a couple of loans but not over the limit
            for (int i = 7; i < 9; i++)
            {
                ILoan loan = _loanDAO.CreateLoan(member[5], book[i], borrowDate, dueDate);
                _loanDAO.CommitLoan(loan);
            }
        }
Пример #33
0
 public void UpdateLoan()//
 {
     loanList.ItemsSource = null;
     lo = Factory.Instance.GLoan();
     loanList.ItemsSource = lo.Loans;
 }
Пример #34
0
        public void AddLoan(ILoan loan)
        {
            if (!BorrowingAllowed)
                throw new ApplicationException($"Borrowing not allowed invalid state: {_state}");

            if (loan == null)
                throw new ArgumentException("Error: Loan is null.");

            _loans.Add(loan);

            CheckState();
        }
Пример #35
0
        public static void LoanInstallment(ILoan loan, double amount)
        {
            ITransaction transaction = new BankTransaction(amount, TypeFactory.PaymentTransaction, DateTime.Now, TypeFactory.GenerateLoanID());

            loan.MakePayment(transaction);
        }