Ejemplo n.º 1
0
        public IActionResult SaveLoanApplication(vmLoanApplication modelData)
        {
            LoanApplication save = new LoanApplication();

            save.LoanId        = modelData.LoanId;
            save.Reason        = modelData.Reason;
            save.AppliedAmount = modelData.AppliedAmount;
            save.InstallmentNo = modelData.InstallmentNo;
            save.AppliedDate   = modelData.AppliedDate;
            save.LoanPeriod    = modelData.LoanPeriod;
            save.ApplierId     = modelData.ApplierId;
            db.LoanApplication.Add(save);
            db.Save();
            int     LoanApplicationId = save.Id;
            decimal InstallmentAmount = Math.Round(modelData.AppliedAmount / modelData.InstallmentNo, 2);

            for (int i = 0; i < modelData.ScheduleDate.Count; i++)
            {
                ProposedLoanInstallment SaveData = new ProposedLoanInstallment();
                SaveData.InstallmentDate   = Convert.ToDateTime(modelData.ScheduleDate[i]);
                SaveData.LoanApplicationId = LoanApplicationId;
                SaveData.Amount            = InstallmentAmount;
                db.ProposedLoanInstallment.Add(SaveData);
                db.Save();
            }
            return(Json("success"));
        }
Ejemplo n.º 2
0
        public IActionResult LoadLoanApplicationTableData()
        {
            var draw          = Request.Form["draw"].FirstOrDefault();
            var start         = Request.Form["start"].FirstOrDefault();
            var length        = Request.Form["length"].FirstOrDefault();
            var sortColumn    = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault();
            var sortColumnDir = Request.Form["order[0][dir]"].FirstOrDefault();
            var searchValue   = Request.Form["search[value]"].FirstOrDefault();

            int pageSize = length != null?Convert.ToInt32(length) : 0;

            int skip = start != null?Convert.ToInt32(start) : 0;

            int recordsTotal = 0;


            List <vmLoanApplication> LoanApplicationList = new List <vmLoanApplication>();
            var AllLoanApplicaton = db.LoanApplication.GetAll();

            //Sorting
            if (!string.IsNullOrEmpty(sortColumn) && !string.IsNullOrEmpty(sortColumnDir))
            {
                // AllLoanApplicaton = AllLoanApplicaton.AsQueryable().OrderBy(sortColumn + " " + sortColumnDir).ToList();
            }
            else
            {
                AllLoanApplicaton = AllLoanApplicaton.OrderByDescending(model => model.Id).ToList();
            }

            //Search
            if (!string.IsNullOrEmpty(searchValue))
            {
                AllLoanApplicaton = AllLoanApplicaton.Where(x => x.Loan.Name.Contains(searchValue) || x.Reason.Contains(searchValue) ||
                                                            x.InstallmentNo == Convert.ToInt32(searchValue) || x.AppliedAmount == Convert.ToInt32(searchValue)
                                                            ).ToList();
            }

            foreach (var items in AllLoanApplicaton)
            {
                vmLoanApplication getData = new vmLoanApplication();
                getData.Id            = items.Id;
                getData.LoanId        = items.LoanId;
                getData.Reason        = items.Reason;
                getData.InstallmentNo = items.InstallmentNo;
                getData.AppliedAmount = items.AppliedAmount;
                getData.LoanPeriod    = items.LoanPeriod;
                getData.AppliedDate   = items.AppliedDate;
                getData.ApplierId     = items.ApplierId;
                LoanApplicationList.Add(getData);
            }


            recordsTotal = LoanApplicationList.Count();

            //Paging
            var data = LoanApplicationList.Skip(skip).Take(pageSize).ToList();

            //Returning Json Data
            return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data }));
        }
Ejemplo n.º 3
0
        public IActionResult UpdateLoanApplication(vmLoanApplication modelData)
        {
            var result = db.LoanApplication.Get(modelData.Id);

            if (result != null)
            {
                result.LoanId        = modelData.LoanId;
                result.AppliedAmount = modelData.AppliedAmount;
                result.Reason        = modelData.Reason;
                result.InstallmentNo = modelData.InstallmentNo;
                db.Save();
                return(Json("success"));
            }
            return(Json("error"));
        }
Ejemplo n.º 4
0
 public IActionResult SaveApprovedLoanApplication(vmLoanApplication modelData)
 {
     if (ModelState.IsValid)
     {
         decimal FinalAmount = Math.Round(modelData.AppliedAmount / modelData.InstallmentNo, 3);
         for (int i = 0; i < modelData.ScheduleDate.Count; i++)
         {
             ApprovedLoanInstallment saveData = new ApprovedLoanInstallment();
             saveData.LoanApplicationId = modelData.Id;
             saveData.Amount            = FinalAmount;
             saveData.InstallmentDate   = modelData.ScheduleDate[i];
             db.ApprovedLoanInstallment.Add(saveData);
             db.Save();
         }
         return(Json(true));
     }
     return(Json(false));
 }