public PerpetualInterestLoan ConvertToPerpetualInterestLoan(AmortizedLoan loan) { PerpetualInterestLoan outputLoan = PerpetualInterestLoan(); copyCommonProperties(loan, outputLoan); return(outputLoan); }
public AmortizedLoan ConvertToAmortizedLoan(PerpetualInterestLoan loan, int term) { AmortizedLoan outputLoan = AmortizedLoan(); copyCommonProperties(loan, outputLoan); outputLoan.Term = term; return outputLoan; }
public AmortizedLoan ConvertToAmortizedLoan(PerpetualInterestLoan loan, int term) { AmortizedLoan outputLoan = AmortizedLoan(); copyCommonProperties(loan, outputLoan); outputLoan.Term = term; return(outputLoan); }
private void initializeListFromDatabase() { if (loanList != null) { return; } loanList = new Dictionary <long, Loan>(); string condition; Dictionary <string, object> parameters = new Dictionary <string, object>(); constructCondition(out condition, parameters); string sql = string.Format("SELECT * FROM loans WHERE {0} ORDER BY start_date", condition); DataTable results = this.database.Query(sql, parameters); foreach (DataRow row in results.Rows) { Loan.LoanType type = (Loan.LoanType) int.Parse(row["type"].ToString()); Loan loan; if (type == Loan.LoanType.AmortizedPayment) { loan = new AmortizedLoan(DatabaseFactory.Default); loan.Term = int.Parse(row["term"].ToString()); } else if (type == Loan.LoanType.InterestOnlyPayment) { loan = new PerpetualInterestLoan(DatabaseFactory.Default); } else { throw new ApplicationException("Invalid loan type found in database"); } loan.Account = account; loan.Id = long.Parse(row["id"].ToString()); loan.InterestRate = decimal.Parse(row["interest"].ToString()); loan.Principal = decimal.Parse(row["principal"].ToString()); loan.Remarks = row["remarks"].ToString(); loan.StartDate = DateTime.Parse(row["start_date"].ToString()); loan.TakenDate = DateTime.Parse(row["taken_date"].ToString()); loanList.Add(loan.Id, loan); } }