コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            LoanDisbursement loandisbursement = db.LoanDisbursements.Find(id);

            db.LoanDisbursements.Remove(loandisbursement);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        //
        // GET: /LoanDisbursement/Details/5

        public ActionResult Details(int id = 0)
        {
            LoanDisbursement loandisbursement = db.LoanDisbursements.Find(id);

            if (loandisbursement == null)
            {
                return(HttpNotFound());
            }
            return(View(loandisbursement));
        }
コード例 #3
0
 public void Delete(LoanDisbursement delObj)
 {
     using (var session = GetSession())
     {
         using (var trans = session.BeginTransaction())
         {
             session.Delete(delObj);
             trans.Commit();
         }
     }
 }
コード例 #4
0
 public void Save(LoanDisbursement saveObj)
 {
     using (var session = GetSession())
     {
         using (var trans = session.BeginTransaction())
         {
             session.FlushMode = FlushMode.Commit;
             session.SaveOrUpdate(saveObj);
             trans.Commit();
             session.Flush();
             //}
         }
     }
 }
コード例 #5
0
 public IActionResult SaveDisbursementData(vmLoanDisbursement DisbursementData)
 {
     if (ModelState.IsValid)
     {
         LoanDisbursement loanDisbursement = new LoanDisbursement();
         loanDisbursement.ApprovedAmount     = DisbursementData.Amount;
         loanDisbursement.DisbursementAmount = DisbursementData.DisbursementAmount;
         loanDisbursement.LoanApplicationId  = DisbursementData.LoanApplicationId;
         db.LoanDisbursement.Add(loanDisbursement);
         db.Save();
         if (loanDisbursement.Id > 0)
         {
             return(Json("success"));
         }
     }
     return(Json("Error"));
 }
コード例 #6
0
 public ActionResult Edit(LoanDisbursement loandisbursement)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loandisbursement).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BranchId = new SelectList(db.Branches, "BranchId", "BranchCode", loandisbursement.BranchId);
     ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "ClientName", loandisbursement.ClientId);
     ViewBag.LoanRepayFreequencyId = new SelectList(db.Freequencies, "FreequencyId", "Freequency1", loandisbursement.LoanRepayFreequencyId);
     ViewBag.LoanApplicationId     = new SelectList(db.LoanApplications, "LoanApplicationId", "LoanApplicationNo", loandisbursement.LoanApplicationId);
     ViewBag.LoanCycleId           = new SelectList(db.LoanCycles, "LoanCycleId", "LoanCycle1", loandisbursement.LoanCycleId);
     ViewBag.LoanStatusId          = new SelectList(db.LoanStatus, "LoanStatusId", "LoanStatus", loandisbursement.LoanStatusId);
     ViewBag.PaymentModeId         = new SelectList(db.PaymentModes, "PaymentModeId", "PaymentMode1", loandisbursement.PaymentModeId);
     ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", loandisbursement.UserId);
     return(View(loandisbursement));
 }
コード例 #7
0
        //
        // GET: /LoanDisbursement/Edit/5

        public ActionResult Edit(int id = 0)
        {
            LoanDisbursement loandisbursement = db.LoanDisbursements.Find(id);

            if (loandisbursement == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BranchId = new SelectList(db.Branches, "BranchId", "BranchCode", loandisbursement.BranchId);
            ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "ClientName", loandisbursement.ClientId);
            ViewBag.LoanRepayFreequencyId = new SelectList(db.Freequencies, "FreequencyId", "Freequency1", loandisbursement.LoanRepayFreequencyId);
            ViewBag.LoanApplicationId     = new SelectList(db.LoanApplications, "LoanApplicationId", "LoanApplicationNo", loandisbursement.LoanApplicationId);
            ViewBag.LoanCycleId           = new SelectList(db.LoanCycles, "LoanCycleId", "LoanCycle1", loandisbursement.LoanCycleId);
            ViewBag.LoanStatusId          = new SelectList(db.LoanStatus, "LoanStatusId", "LoanStatus", loandisbursement.LoanStatusId);
            ViewBag.PaymentModeId         = new SelectList(db.PaymentModes, "PaymentModeId", "PaymentMode1", loandisbursement.PaymentModeId);
            ViewBag.UserId = new SelectList(db.Users, "Id", "UserName", loandisbursement.UserId);
            return(View(loandisbursement));
        }
コード例 #8
0
        public ActionResult Create(LoanRepayment loanrepayment, string Advance)
        {
            if (ModelState.IsValid)
            {
                db.LoanRepayments.Add(loanrepayment);
                db.SaveChanges();

                // Update repay balance in Disbursement table

                decimal amountPaid = db.LoanRepayments.Where(x => x.LoanDisbursementId == loanrepayment.LoanDisbursementId && x.LoanCycleId == loanrepayment.LoanCycleId).Sum(x => x.AmountPaid).Value;

                LoanDisbursement loanDisburseRecord = db.LoanDisbursements.Where(x => x.LoanDisbursementId == loanrepayment.LoanDisbursementId && x.LoanCycleId == loanrepayment.LoanCycleId).FirstOrDefault();
                decimal          actualPaidLoanAmt  = 0;
                if (loanDisburseRecord != null)
                {
                    actualPaidLoanAmt = loanDisburseRecord.TotalRepayAmountWithInterest.Value;
                    loanDisburseRecord.LoanRepayBalance = loanDisburseRecord.LoanRepayBalance - loanrepayment.AmountPaid.Value;
                }

                decimal remainLoanBalance = actualPaidLoanAmt - amountPaid;

                if (remainLoanBalance <= 0)
                {
                    //Update Status in disbursement when all amount paid
                    // Change loan status
                    loanDisburseRecord.LoanStatusId = 2;
                }
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.BranchId           = new SelectList(db.Branches, "BranchId", "BranchCode", loanrepayment.BranchId);
            ViewBag.ClientId           = new SelectList(db.Clients, "ClientId", "ClientName", loanrepayment.ClientId);
            ViewBag.LoanApplicationId  = new SelectList(db.LoanApplications, "LoanApplicationId", "LoanApplicationNo", loanrepayment.LoanApplicationId);
            ViewBag.LoanCycleId        = new SelectList(db.LoanCycles, "LoanCycleId", "LoanCycle1", loanrepayment.LoanCycleId);
            ViewBag.LoanDisbursementId = new SelectList(db.LoanDisbursements, "LoanDisbursementId", "DisbursementCode", loanrepayment.LoanDisbursementId);
            ViewBag.LoanEMIScheduletId = new SelectList(db.LoanEMISchedules, "LoanEMIScheduleId", "EMIDate", loanrepayment.LoanEMIScheduletId);
            ViewBag.RepaymentStatusId  = new SelectList(db.LoanRepaymentStatus, "LoanRepaymentStatusId", "LoanRepaymentStatus", loanrepayment.RepaymentStatusId);
            ViewBag.UserId             = new SelectList(db.Users, "Id", "UserName", loanrepayment.UserId);
            return(View(loanrepayment));
        }
コード例 #9
0
        public ActionResult Create(LoanDisbursement loandisbursement)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var IsLoanAlreadyDisbursed = db.LoanDisbursements.Where(x => x.LoanApplicationId == loandisbursement.LoanApplicationId &&
                                                                            x.LoanCycleId == loandisbursement.LoanCycleId).FirstOrDefault();

                    if (IsLoanAlreadyDisbursed == null)
                    {
                        if (loandisbursement.EMIStartDate == null)
                        {
                            loandisbursement.EMIStartDate = DateTime.Now;
                        }

                        if (loandisbursement.DisbursmentDate == null)
                        {
                            loandisbursement.DisbursmentDate = DateTime.Now;
                        }
                        loandisbursement.LoanRepayBalance = loandisbursement.TotalRepayAmountWithInterest;
                        db.LoanDisbursements.Add(loandisbursement);
                        db.SaveChanges();

                        int id = loandisbursement.LoanDisbursementId;

                        //Create Schedule

                        for (int i = 0; i < loandisbursement.TimePeriod; i++)
                        {
                            db.LoanEMISchedules.Add(new LoanEMISchedule
                            {
                                LoanDisbursementId = id,
                                EMIDate            = loandisbursement.EMIStartDate.Value.AddDays(i),
                                EMI             = loandisbursement.LoanEMI,
                                ScheduleDate    = DateTime.Now,
                                Balance         = loandisbursement.TotalRepayAmountWithInterest - (loandisbursement.LoanEMI * (i + 1)),
                                PrincipleAmount = loandisbursement.LoanEMI,
                                InterestAmount  = 0
                            });
                        }

                        db.SaveChanges();

                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewBag.BranchId = new SelectList(db.Branches, "BranchId", "BranchCode", loandisbursement.BranchId);
                        ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "ClientName", loandisbursement.ClientId);
                        ViewBag.LoanRepayFreequencyId = new SelectList(db.Freequencies, "FreequencyId", "Freequency1", loandisbursement.LoanRepayFreequencyId);
                        ViewBag.LoanApplicationId     = new SelectList(db.LoanApplications, "LoanApplicationId", "LoanApplicationNo", loandisbursement.LoanApplicationId);
                        ViewBag.LoanCycleId           = new SelectList(db.LoanCycles, "LoanCycleId", "LoanCycle1", loandisbursement.LoanCycleId);
                        ViewBag.LoanStatusId          = new SelectList(db.LoanStatus, "LoanStatusId", "LoanStatus", loandisbursement.LoanStatusId);
                        ViewBag.PaymentModeId         = new SelectList(db.PaymentModes, "PaymentModeId", "PaymentMode1", loandisbursement.PaymentModeId);
                        ViewBag.UserId           = new SelectList(db.Users, "Id", "UserName", loandisbursement.UserId);
                        ViewBag.DisbursementCode = GetLoanDisbursementCode();
                        ViewBag.DisbursementDate = DateTime.Now.ToShortDateString();
                        ViewBag.Message          = "This Loan application already disbursed you can change the cycle and procced.";
                        return(View(loandisbursement));
                    }
                }

                ViewBag.BranchId = new SelectList(db.Branches, "BranchId", "BranchCode", loandisbursement.BranchId);
                ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "ClientName", loandisbursement.ClientId);
                ViewBag.LoanRepayFreequencyId = new SelectList(db.Freequencies, "FreequencyId", "Freequency1", loandisbursement.LoanRepayFreequencyId);
                ViewBag.LoanApplicationId     = new SelectList(db.LoanApplications, "LoanApplicationId", "LoanApplicationNo", loandisbursement.LoanApplicationId);
                ViewBag.LoanCycleId           = new SelectList(db.LoanCycles, "LoanCycleId", "LoanCycle1", loandisbursement.LoanCycleId);
                ViewBag.LoanStatusId          = new SelectList(db.LoanStatus, "LoanStatusId", "LoanStatus", loandisbursement.LoanStatusId);
                ViewBag.PaymentModeId         = new SelectList(db.PaymentModes, "PaymentModeId", "PaymentMode1", loandisbursement.PaymentModeId);
                ViewBag.UserId           = new SelectList(db.Users, "Id", "UserName", loandisbursement.UserId);
                ViewBag.DisbursementCode = GetLoanDisbursementCode();
                ViewBag.DisbursementDate = DateTime.Now.ToShortDateString();
                return(View(loandisbursement));
            }
            catch (Exception ex)
            {
                ILog.debug("Message: " + ex.Message + "Inner Exception: " + ex.InnerException + "Stack trace:" + ex.StackTrace);
                return(RedirectToAction("Index"));
            }
        }