Ejemplo n.º 1
0
        public ActionResult CreateLoanRequestDecision()
        {
            Db db = new Db(DbServices.ConnectionString);
            ManageLoanDecision vm = new ManageLoanDecision();

            vm.LoanRequestVwViewModel.List = LoanRequestVwServices.List(db).Where(c => c.RequestRequestStatusId.Value == (int)RequestStatusEnum.FinanciallyApproved).ToList();

            return(View(vm));
        }
Ejemplo n.º 2
0
        public ActionResult CreateLoanRequestDecision(ManageLoanDecision model)
        {
            try
            {
                Db db = new Db(DbServices.ConnectionString);

                if (ModelState.IsValid)
                {
                    try
                    {
                        int numberOfCheckedRequests = model.Requests.Where(c => c.isChecked).Count();

                        if (numberOfCheckedRequests != 0)
                        {
                            // 1- Add Loan Decision
                            model.LoanDecision.LoanDecisionType = (int)LoanDecisionTypeEnum.Normal;
                            if (model.LoanDecision.IsPaidFromSalary == null)
                            {
                                model.LoanDecision.IsPaidFromSalary = false;
                            }
                            LoanDecision instance = LoanDecisionServices.Insert(CurrentUser.Id, model.LoanDecision, db);

                            // 2- Add Loans
                            for (int i = 0; i < model.Requests.Count; i++)
                            {
                                if (!model.Requests[i].isChecked)
                                {
                                    continue;
                                }
                                db.LoanGenerate(model.Requests[i].RequestId, instance.Id, (int)LoanGenerationStatusEnum.LoanRequest);
                            }
                            TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch (CfException cfex)
                    {
                        TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                    }
                    catch (Exception ex)
                    {
                        TempData["Failure"] = ex.Message;
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }