Exemplo n.º 1
0
        public bool Create(LoanBusinessEntity loanBusinessEntity)
        {
            LoanDAL loanDAL = new LoanDAL();

            loanBusinessEntity = GenerateLoanNo(loanBusinessEntity);
            return(loanDAL.Save(loanBusinessEntity));
        }
Exemplo n.º 2
0
        public LoanBusinessEntity GetLoanNo(LoanBusinessEntity loanBusinessEntity)
        {
            int      counts;
            string   last = "";
            tbl_Loan lastloan;

            using (var count = new LoanManagementSystemEntities())
            {
                counts = count.tbl_Loan.Count();
            }
            if (counts == 0)
            {
                last = "L000001";
            }
            else
            {
                using (var dbContext = new LoanManagementSystemEntities())
                {
                    var lnk = dbContext.tbl_Loan.OrderByDescending(x => x.LoanNo).Take(1);
                    lastloan = lnk.First();
                    last     = lastloan.LoanNo;
                }
                //int number = Convert.ToInt32(last.Substring(1)) + 1;
                int number = int.Parse(last.Substring(1));
                number += 1;

                string symbol = last.Substring(0, 1);
                last = symbol + number.ToString("D6"); /////great formating solution
            }

            loanBusinessEntity.LoanNo = last;
            return(loanBusinessEntity);
        }
Exemplo n.º 3
0
        public List <LoanBusinessEntity> GetLoans()
        {
            List <LoanBusinessEntity> loans = new List <LoanBusinessEntity>();

            try
            {
                using (var dbContext = new LoanManagementSystemEntities())
                {
                    var dbLoanObj = dbContext.tbl_Loan.ToList();

                    foreach (var loan in dbLoanObj)
                    {
                        LoanBusinessEntity loanBusinessEntity = new LoanBusinessEntity();
                        loanBusinessEntity.Id         = loan.Id;
                        loanBusinessEntity.LoanNo     = loan.LoanNo;
                        loanBusinessEntity.LoanStatus = loan.LoanStatus;
                        loanBusinessEntity.LoanTypeId = loan.LoanTypeId;

                        loanBusinessEntity.Amount = (double)loan.Amount;

                        loanBusinessEntity.CustomerId = (int)loan.CustomerId;
                        loans.Add(loanBusinessEntity);
                    }
                }
            }
            catch
            {
                throw;
            }
            finally
            {
            }
            return(loans);
        }
Exemplo n.º 4
0
        public ActionResult Create(LoanBusinessEntity loanBusinessEntity)
        {
            loanBusinessEntity.Id = -1;
            string str    = "Success";
            LoanBL loanBL = new LoanBL();
            bool   status = loanBL.Create(loanBusinessEntity);

            return(Json(str, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        public ActionResult SearchLoan()
        {
            LoanBL loanBL = new LoanBL();
            IList <LoanBusinessEntity> loans    = loanBL.GetLoans();
            List <LoanBusinessEntity>  loansnew = new List <LoanBusinessEntity>();

            foreach (LoanBusinessEntity loan in loans)
            {
                LoanBusinessEntity ob = GetCustName(loan);
                loansnew.Add(ob);
            }
            return(Json(loansnew, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
 public LoanBusinessEntity GetCustName(LoanBusinessEntity loanBusinessEntity)
 {
     try
     {
         using (var dbContext = new LoanManagementSystemEntities())
         {
             tbl_Customer cust = dbContext.tbl_Customer.Where(c => c.Id == loanBusinessEntity.CustomerId).FirstOrDefault();
             if (cust != null)
             {
                 loanBusinessEntity.CustomerName = cust.Name;
             }
         }
     }
     catch (Exception ex)
     {
     }
     finally
     {
     }
     return(loanBusinessEntity);
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        public LoanBusinessEntity GetCustName(LoanBusinessEntity loanBusinessEntity)
        {
            LoanBL loanBL = new LoanBL();

            return(loanBL.GetCustName(loanBusinessEntity));
        }
Exemplo n.º 10
0
        private LoanBusinessEntity GenerateLoanNo(LoanBusinessEntity loanBusinessEntity)
        {
            LoanDAL loanDAL = new LoanDAL();

            return(loanDAL.GetLoanNo(loanBusinessEntity));
        }