Esempio n. 1
0
        private ActionResult GetCalculateCreditResult(CalculateCreditModel calculateCreditModel)
        {
            var calculatedData = this.creditManager.CalculateCredit(
                calculateCreditModel.LoanProductId,
                calculateCreditModel.Amount,
                calculateCreditModel.Monthes);

            // one more magic:) linque-magic:)
            var months = -calculatedData.Payments.Count() + 1;
            var model = new CalculationResultModel
                            {

                                MonthlyPayments = calculatedData.Payments.Select(x => new MonthlyPaymentViewModel
                                        {
                                            Payment = x.ToGBString(),
                                            Month = DateTime.Today.AddMonths(months++).ToString("MMMMMMMMMM / yyyy", CultureInfo.InvariantCulture)
                                        }),
                                TotalPayment = calculatedData.TotalPayment.ToGBString()
                            };
            switch (calculateCreditModel.LoanProductType)
            {
                case LoanProductType.Anuitet:
                    return this.View("CreditCalulator/CalculationResult/AnuitetCalculationResult", model);
                case LoanProductType.Differential:
                    return this.View("CreditCalulator/CalculationResult/DifferencialCalculationResult", model);
                case LoanProductType.OneTimePayment:
                    return this.View("CreditCalulator/CalculationResult/OneTimePaymentCalculationResult", model);
                default:
                    throw new NotSupportedException();
            }
        }
Esempio n. 2
0
 public ActionResult CalculateCredit(CalculateCreditModel creditModel)
 {
     return this.GetCalculateCreditResult(creditModel);
 }