Exemple #1
0
 private LoanProduct MapLoanProduct(LoanProductViewModel model, LoanProduct loanProduct)
 {
     loanProduct.Id                = model.LoanProductId;
     loanProduct.MinAmount         = model.MinAmount;
     loanProduct.MaxAmount         = model.MaxAmount;
     loanProduct.Percentage        = model.Percentage;
     loanProduct.MinPeriodInMonth  = model.MinPeriodInMonth;
     loanProduct.MaxPeriodInMonth  = model.MaxPeriodInMonth;
     loanProduct.Name              = model.Name;
     loanProduct.Description       = model.Description;
     loanProduct.Type              = model.Type;
     loanProduct.Status            = LoanProductStatus.Draft;
     loanProduct.FineDayPercentage = model.FineDayPercentage;
     loanProduct.AdvancedRepaymentFirstPossibleMonth = model.AdvancedRepaymentFirstPossibleMonth;
     loanProduct.AdvancedRepaymentFinePercentage     = model.AdvancedRepaymentFinePercentage;
     loanProduct.Requirements.Id = model.Requirements.LoanProductRequirementsId;
     loanProduct.Requirements.MinWorkOnLastJobInMonths = model.Requirements.MinWorkOnLastJobInMonths;
     loanProduct.Requirements.MinSalary          = model.Requirements.MinSalary;
     loanProduct.Requirements.NeedEarningsRecord = model.Requirements.NeedEarningsRecord;
     loanProduct.Requirements.NeedGuarantors     = model.Requirements.NeedGuarantors;
     loanProduct.Requirements.GuarantorsCount    = model.Requirements.GuarantorsCount;
     loanProduct.Requirements.Approvers          =
         this.userService.GetRoles()
         .Where(x => model.Requirements.Approvers.Select(approver => approver.ToString()).Contains(x.Name))
         .ToList();
     return(loanProduct);
 }
Exemple #2
0
        public ActionResult EditCredit(LoanProductViewModel model)
        {
            LoanProduct loanProduct = this._creditService.GetLoanProduct(model.LoanProductId);

            this.MapLoanProduct(model, loanProduct);
            this._creditService.Save(loanProduct);
            return(this.Json(true));
        }
Exemple #3
0
        private LoanProductViewModel GetModelFromLoanProduct(LoanProduct loanProduct)
        {
            var model = new LoanProductViewModel
            {
                MinAmount         = loanProduct.MinAmount,
                MaxAmount         = loanProduct.MaxAmount,
                Percentage        = loanProduct.Percentage,
                MinPeriodInMonth  = loanProduct.MinPeriodInMonth,
                MaxPeriodInMonth  = loanProduct.MaxPeriodInMonth,
                Name              = loanProduct.Name,
                Description       = loanProduct.Description,
                Type              = loanProduct.Type,
                FineDayPercentage = loanProduct.FineDayPercentage,
                AdvancedRepaymentFirstPossibleMonth =
                    loanProduct.AdvancedRepaymentFirstPossibleMonth,
                AdvancedRepaymentFinePercentage =
                    loanProduct.AdvancedRepaymentFinePercentage,
                LoanProductId = loanProduct.Id,
                Requirements  =
                    new LoanProductRequirementsViewModel
                {
                    LoanProductRequirementsId = loanProduct.Requirements.Id,
                    MinWorkOnLastJobInMonths
                        =
                            loanProduct
                            .Requirements
                            .MinWorkOnLastJobInMonths,
                    MinSalary =
                        loanProduct
                        .Requirements
                        .MinSalary,
                    NeedEarningsRecord =
                        loanProduct
                        .Requirements
                        .NeedEarningsRecord,
                    NeedGuarantors =
                        loanProduct
                        .Requirements
                        .NeedGuarantors,
                    GuarantorsCount =
                        loanProduct
                        .Requirements
                        .GuarantorsCount,
                    Approvers =
                        loanProduct
                        .Requirements
                        .Approvers.Select(
                            identityRole =>
                            (Role)
                            Enum.Parse(
                                typeof(Role),
                                identityRole
                                .Name))
                }
            };

            return(model);
        }
Exemple #4
0
        public ActionResult CreateCredit(LoanProductViewModel model)
        {
            Contract.Requires <ArgumentNullException>(model.IsNotNull());
            if (!this.ModelState.IsValid)
            {
                return(this.PartialView("CreateCreditFields", model));
            }

            var loanProduct = MapLoanProduct(model, new LoanProduct {
                Requirements = new LoanProductRequirements()
            });


            var result = this._creditService.CreateLoanProduct(loanProduct);

            return(this.Json(result));
        }