public bool UpdateLoan(int loanId, LoanModel loanModel) { var success = false; if (loanModel != null) { using (var scope = new TransactionScope()) { var loan = _unitOfWork.LoanRepository.GetById(loanId); if (loan != null) { loan.AccountName = loanModel.AccountName; loan.AccountNo = loanModel.AccountNo; loan.Balance = loanModel.Balance; loan.Interest = loanModel.Interest; loan.EarlyPaymentFee = loanModel.EarlyPaymentFee; loan.Carryover = loanModel.Carryover; _unitOfWork.LoanRepository.Update(loan); _unitOfWork.Save(); scope.Complete(); success = true; } } } return(success); }
private async void LoadLoan() { LoanModel l = await loans.GetSingle(loanId); BorrowerModel b = await borrowers.GetSingle(l.BorrowerId); txtId.Text = b.BorrowerID; txtName.Text = b.FirstName + " " + b.MiddleName[0] + ". " + b.LastName; txtLoanId.Text = l.LoanId; txtDuration.Text = l.Duration.ToString(); txtEffectiveDate.Text = ConvertDate(l.EffectiveDate); txtInterest.Text = l.Interest.ToString(); txtMaturityDate.Text = ConvertDate(l.MaturityDate); txtPerRemittance.Text = l.PerRemittance.ToString(); txtPrincipal.Text = l.PrincipalLoan.ToString(); txtMaturityValue.Text = l.MaturityValue.ToString(); txtTotalBalance.Text = l.TotalBalance.ToString(); cboPaymentTerm.SelectedValue = l.InterestId; txtCollector.Text = users.GetSingle(" ", l.CollectorId).Name; gName.Text = l.Guarantor.Name; gAddress.Text = l.Guarantor.Address; gContacts.Text = l.Guarantor.ContactNumber; gRelation.Text = l.Guarantor.Relationship; cValue.Text = l.Collateral.Value.ToString(); cItem.Text = l.Collateral.Item; cDescription.Text = l.Collateral.Description; btnPrint.Visible = true; int _id = int.Parse(cboPaymentTerm.SelectedValue.ToString()); double interest = interests.getInterest(_id); txtInterestRate.Text = $"{interest: ##.##}%"; Generate(); }