private tbl_Loan GetLoan(int ID) { var dbloan = new tbl_Loan(); using (var dbContext = new LoanManagementSystemEntities()) { dbloan = dbContext.tbl_Loan.Where(loan => loan.Id == ID).FirstOrDefault(); return(dbloan); } }
private void AssignValues(ref tbl_Loan Dbloan, ref LoanBusinessEntity loanBusinessEntity) { Dbloan.LoanNo = loanBusinessEntity.LoanNo; Dbloan.LoanTypeId = loanBusinessEntity.LoanTypeId; Dbloan.Nominee = loanBusinessEntity.Nominee; Dbloan.NoOfInstallaments = loanBusinessEntity.NoOfInstallments; Dbloan.interestrate = (Double)loanBusinessEntity.intrestrate; Dbloan.NomineeRelationShip = loanBusinessEntity.NomineeRelationShip; Dbloan.CustomerId = loanBusinessEntity.CustomerId; Dbloan.Amount = (decimal)loanBusinessEntity.Amount; }
public bool Save(LoanBusinessEntity loanBusinessEntity) { tbl_Loan Dbloan; if (loanBusinessEntity.Id == -1) { Dbloan = new tbl_Loan(); } else { Dbloan = GetLoan(loanBusinessEntity.Id); } AssignValues(ref Dbloan, ref loanBusinessEntity); using (var dbContext = new LoanManagementSystemEntities()) { dbContext.tbl_Loan.Add(Dbloan); dbContext.SaveChanges(); } return(true); }