// method for sending new loan details to databse and returning result public bool NewLoanDetails(Loan loan, string cr) { //decimal atb, int repaymentPeriod, string creditRating decimal atb = loan.ATB; int rp = loan.RepaymentPeriod; decimal loanBalance = loan.ATB; bool result = false; loan.LoanApplicationDate = DateTime.Today; loan.MonthlyRepayment = GetMontlyRepayment(atb, rp, cr); loan.PaymentsMade = 0; loan.LoanBalance = loanBalance; loan.LoanStatus = "Pending"; loan.OutstandingLoans = GetOutstandingLoan(loan); if (loan.OutstandingLoans == true) { loan.OutstandingLoansValue += GetOutstandingLoanValue(loan); } //string result = String.Empty; try { DALLoanManager DALMngr = new DALLoanManager(); result = DALMngr.PassNewLoanDetails(loan); return result; } catch (Exception ex) { throw; } }
// method which checks for bad credit private bool CheckForBadCredit(int crn) { //DateTime DateEnd = DateTime.Now; //DateTime DateStart = DateEnd - new TimeSpan(365, 0, 0, 0); List<Loan> LoanList = null; Loan loan = null; bool result = false; //DateTime Past3Years = DateTime.Now.AddYears(-3); DateTime dateTimeNow = DateTime.Now; //DateTime Past3Years = dateTimeToday.AddYears(-3); DateTime ThreeYearsAgo = dateTimeNow - new TimeSpan(1095, 0, 0, 0); try { DALLoanManager DALMngr = new DALLoanManager(); LoanList = DALMngr.CallGetLoanList(); foreach (Loan l in LoanList) { if (l.CRN == crn) { loan = l; if ((loan.LoanStatus == "LPIA" || loan.LoanStatus == "CRBD" || loan.LoanStatus == "CRCCJ") && (loan.LoanCommencementDate > ThreeYearsAgo)) { // not eligible result = true; } } } } catch (Exception ex) { throw; } return result; }
// method to return the value of an applicant's outstanding loan private decimal GetOutstandingLoanValue(Loan loan) { List<Loan> LoanList = null; decimal loansValue = 0; try { DALLoanManager DALMngr = new DALLoanManager(); LoanList = DALMngr.CallGetLoanList(); foreach (Loan l in LoanList) { if (l.CRN == loan.CRN) { loansValue = l.OutstandingLoansValue; } } } catch (Exception ex) { throw; } return loansValue; }
// method to return whether an applicant has an outstanding loan private bool GetOutstandingLoan(Loan loan) { List<Loan> LoanList = null; bool outLoans = false; try { DALLoanManager DALMngr = new DALLoanManager(); LoanList = DALMngr.CallGetLoanList(); foreach (Loan l in LoanList) { if (l.CRN == loan.CRN) { if (l.OutstandingLoans == true) { outLoans = true; } } } } catch (Exception ex) { throw; } return outLoans; }
// method which sends the updated details of an approved loan to the DAL public bool ApproveLoanDetails(Loan loan) { bool result = false; loan.LoanCommencementDate = DateTime.Today; loan.OutstandingLoans = true; loan.OutstandingLoansValue += loan.ATB; loan.LoanStatus = "Live"; try { DALLoanManager DALMngr = new DALLoanManager(); result = DALMngr.CallApproveLoanToDB(loan); } catch (Exception ex) { throw; } return result; }
// send loan payment details to DAL private bool MakeLoanPayment(Loan loan) { bool result = false; try { DALLoanManager DALMngr = new DALLoanManager(); result = DALMngr.PassLoanPaymentDetailsToDB(loan); } catch (Exception ex) { throw; } return result; }
// send updated loan details to data access layer private bool UpdatedLoanDetails(Loan loan) { bool result = false; try { DALLoanManager DALMngr = new DALLoanManager(); result = DALMngr.PassUpdatedLoanDetailsToDB(loan); } catch (Exception ex) { throw; } return result; }
//method for returning list of loans private List<Loan> GetListOfLoans() { List<Loan> LoanList = new List<Loan>(); try { DALLoanManager DALMngr = new DALLoanManager(); LoanList = DALMngr.CallGetLoanList(); } catch (Exception ex) { throw; } return LoanList; }