Ejemplo n.º 1
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);
        }
        public CustomerBusinessEntity GetCustomerById(int ID)
        {
            CustomerBusinessEntity customer = new CustomerBusinessEntity();

            try
            {
                using (var dbContext = new LoanManagementSystemEntities())
                {
                    tbl_Customer cust = dbContext.tbl_Customer.Where(c => c.Id == ID).FirstOrDefault();
                    if (cust != null)
                    {
                        customer.ID      = cust.Id;
                        customer.Name    = cust.Name;
                        customer.PanCard = cust.PANCard;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
            return(customer);
        }
Ejemplo n.º 3
0
        public List <CustomerBusinessEntity> List()
        {
            List <CustomerBusinessEntity> customers = new List <CustomerBusinessEntity>();

            try
            {
                using (var dbContext = new LoanManagementSystemEntities())
                {
                    var dbCustomers = dbContext.tbl_Customer.ToList();
                    customers = dbCustomers.Select(db => new CustomerBusinessEntity()
                    {
                        ID           = db.Id,
                        Name         = db.Name,
                        AnnualIncome = (double)db.AnnualIncome,
                        PanCard      = db.PANCard
                    }).ToList();
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(customers);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        private tbl_Customer Get(int id)
        {
            tbl_Customer dbcust;

            using (var dbContext = new LoanManagementSystemEntities())
            {
                dbcust = dbContext.
                         tbl_Customer.
                         Where(cust => cust.Id == id).FirstOrDefault();
            }
            return(dbcust);
        }
Ejemplo n.º 7
0
        }         //end of method

        public UserEntity Get(int id)
        {
            UserEntity userEntity = new UserEntity();

            using (var dbContext = new LoanManagementSystemEntities())
            {
                var dbUser = dbContext.tbl_LMSUser.Where(user => user.Id == id).FirstOrDefault();
                userEntity.Id                 = dbUser.Id;
                userEntity.Name               = dbUser.Name;
                userEntity.Password           = dbUser.Password;
                userEntity.MobileNo           = dbUser.MobileNo;
                userEntity.EmailId            = dbUser.EmailId;
                userEntity.Role               = dbUser.Role;
                userEntity.SecurityQuestionId = dbUser.SecurityQuestionId.Value;
                userEntity.Answer             = dbUser.Answer;
            }
            return(userEntity);
        }
Ejemplo n.º 8
0
 public void Insert(UserEntity userEntity)
 {
     using (var dbContext = new LoanManagementSystemEntities())
     {
         tbl_LMSUser dbUser = new tbl_LMSUser();
         dbUser.Name               = userEntity.Name;
         dbUser.Password           = userEntity.Password;
         dbUser.MobileNo           = userEntity.MobileNo;
         dbUser.EmailId            = userEntity.EmailId;
         dbUser.Role               = userEntity.Role;
         dbUser.IsActive           = userEntity.IsActive;
         dbUser.IsLocked           = userEntity.IsLocked;
         dbUser.SecurityQuestionId = userEntity.SecurityQuestionId;
         dbUser.Answer             = userEntity.Answer;
         dbContext.tbl_LMSUser.Add(dbUser);
         dbContext.SaveChanges();
     }
 }
        public List <LoanTypeEntity> GetLoanTypes()
        {
            List <LoanTypeEntity> loantypes = new List <LoanTypeEntity>();

            using (var dbLMSEntities = new LoanManagementSystemEntities())
            {
                var dbLoanTypes = dbLMSEntities.tbl_LoanTypes.ToList();
                foreach (var dbLoanType in dbLoanTypes)
                {
                    LoanTypeEntity loanTypeEntity = new LoanTypeEntity();
                    loanTypeEntity.Id              = dbLoanType.Id;
                    loanTypeEntity.LoanName        = dbLoanType.LoanName;
                    loanTypeEntity.IntrestRate     = (double)dbLoanType.IntrestRate;
                    loanTypeEntity.MaxInstallments = (int)dbLoanType.MaxInstallments;
                    loanTypeEntity.MaxAmount       = (decimal)dbLoanType.MaxAmount;
                    loantypes.Add(loanTypeEntity);
                }
            }
            return(loantypes);
        }
Ejemplo n.º 10
0
 public void Update(UserEntity userEntity)
 {
     using (var dbContext = new LoanManagementSystemEntities())
     {
         var existingDBUser = dbContext.tbl_LMSUser.Where(u => u.Id == userEntity.Id).FirstOrDefault();
         UpdateDBUserInfo(ref existingDBUser, ref userEntity);
         //existingDBUser.Name = userEntity.Name;
         //existingDBUser.Password = userEntity.Password;
         //existingDBUser.MobileNo = userEntity.MobileNo;
         //existingDBUser.EmailId = userEntity.EmailId;
         //existingDBUser.Role = userEntity.Role;
         //existingDBUser.IsActive = userEntity.IsActive;
         //existingDBUser.IsLocked = userEntity.IsLocked;
         //existingDBUser.SecurityQuestionId = userEntity.SecurityQuestionId;
         //existingDBUser.Answer = userEntity.Answer;
         //existingDBUser.CreatedDate = DateTime.Now;
         //existingDBUser.CreatedBy="1";
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 11
0
        public List <UserEntity> List()
        {
            List <UserEntity> users = new List <UserEntity>();

            using (var dbContext = new LoanManagementSystemEntities())
            {
                var dbUsers = dbContext.tbl_LMSUser.ToList();

                foreach (var dbUser in dbUsers)
                {
                    UserEntity userEntity = new UserEntity();
                    userEntity.Name     = dbUser.Name;
                    userEntity.MobileNo = dbUser.MobileNo;
                    userEntity.EmailId  = dbUser.EmailId;
                    userEntity.Id       = dbUser.Id;
                    users.Add(userEntity);
                } // end of for
            }     // end of using
            return(users);
        }         //end of method
        public List <QuestionEntity> GetQuestions()
        {
            List <QuestionEntity> questions = new List <QuestionEntity>();

            using (var dbLMSEntities = new LoanManagementSystemEntities())
            {
                using (var sw = new StreamWriter(@"C:\Users\NIHAR-PC\OneDrive\Attachments\log.txt"))
                {
                    dbLMSEntities.Database.Log = sw.WriteLine;
                    var dbQuestions = dbLMSEntities.Questions.ToList();
                    foreach (var dbQuestion in dbQuestions)
                    {
                        QuestionEntity questionEntity = new QuestionEntity();
                        questionEntity.Id           = dbQuestion.id;
                        questionEntity.QuestionName = dbQuestion.QuestionName;
                        questions.Add(questionEntity);
                    }
                }
            }
            return(questions);
        }
Ejemplo n.º 13
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);
 }
Ejemplo n.º 14
0
        public bool Save(CustomerBusinessEntity customer)
        {
            tbl_Customer dbCustomer;

            if (customer.ID == -1)
            {
                dbCustomer = new tbl_Customer();
            }
            else
            {
                dbCustomer = Get(customer.ID);
            }
            AssignValueToDBCustomer(ref dbCustomer, ref customer);
            using (var dbContext = new LoanManagementSystemEntities())
            {
                dbContext.tbl_Customer.Add(dbCustomer);
                dbContext.SaveChanges();
            }

            return(true);
        }
Ejemplo n.º 15
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);
        }