Ejemplo n.º 1
0
        public bool AddLoanAccountRequest(LoanRequestViewModel request)
        {
            bool result = false;

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Database1ConnectionString"].ToString()))
            {
                int requestID;

                SqlCommand command = new SqlCommand("SELECT Count(RequestID) FROM LoanRequest ", connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                string customerName = GetCustomerNamebyCustomerID(request.customerID);

                reader.Read();
                requestID = Convert.ToInt16(reader[0]) + 1;
                reader.Close();

                command.CommandText = String.Format("INSERT INTO LoanRequest (RequestID, TypeOfLoan, CustomerID, SubmissionDate, Status, BranchCode, AnnualIncome, Amount, Tenure, AddressProof, SalaryProof, CustomerName) VALUES('{0}', '{1}', '{2}', '{3}', 'S', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}') ", requestID, request.typeOfLoan, request.customerID, DateTime.Now.ToString(), request.branchName, request.annualIncome.ToString(), request.amount.ToString(), request.tenure.ToString(), request.addressProof, request.salaryProof, customerName);

                if (command.ExecuteNonQuery() > 0)
                    result = true;

            }
            return result;
        }
Ejemplo n.º 2
0
        public ActionResult ApplyForLoan()
        {
            CommonDAL objCommonDal = new CommonDAL();
            ViewBag.cityList = objCommonDal.GetCityList();
            long customerID = (Session["User"] as UserRole).customerID;
            CustomerDAL objCustomerDal = new CustomerDAL();
            LoanRequestViewModel objLoanRequest = new LoanRequestViewModel();
            objLoanRequest.customerID = customerID;
            objLoanRequest.age = objCustomerDal.GetAgeByCustomerID(customerID);
            objLoanRequest.salaryProof = new byte[1024];
            objLoanRequest.addressProof = new byte[1024];
            @ViewBag.loanTypeList = new List<SelectListItem>()
            {
                new SelectListItem(){Text = "Personal",Value="P"},
                new SelectListItem(){Text = "Home",Value="H"},
                new SelectListItem(){Text = "Vehicle",Value="V"},
            };

            return View(objLoanRequest);
        }
Ejemplo n.º 3
0
        public ActionResult ApplyForLoan(LoanRequestViewModel model)
        {
            CommonDAL objCommonDal = new CommonDAL();
            CustomerDAL objCustomerDal = new CustomerDAL();
            ViewBag.cityList = objCommonDal.GetCityList();
            @ViewBag.loanTypeList = new List<SelectListItem>()
            {
                new SelectListItem(){Text = "Personal",Value="P"},
                new SelectListItem(){Text = "Home",Value="H"},
                new SelectListItem(){Text = "Vehicle",Value="V"},
            };
            if(objCustomerDal.AddLoanAccountRequest(model) )
            {
                ModelState.AddModelError("", "You request for loan was successful. You may apply for yet another loan");
            }
            else
            {
                ModelState.AddModelError("", "Operation failed");
            }

            return View(model);
        }