コード例 #1
0
        public IActionResult Details([FromServices] MaaContext maaContext, long id)
        {
            MortgageApprovalApplication mortgageApprovalApplication = MortgageApprovalApplication.Get(maaContext, id);

            //return View(mortgageApprovalApplication);
            return(View(mortgageApprovalApplication));
        }
コード例 #2
0
        public IActionResult Index([FromServices] MaaContext maaContext)
        {
            Dictionary <long, double> interestDictionary = Interest.GetAll(maaContext);

            ViewBag.VBInterestList = interestDictionary;
            return(View("Application"));
        }
コード例 #3
0
        public IActionResult List([FromServices] MaaContext maaContext)
        {
            var applications = from application in maaContext.MortgageApprovalApplication
                               orderby application.Id descending
                               select application;

            return(View(applications.ToList()));
        }
コード例 #4
0
        public IActionResult Submit([FromServices] MaaContext maaContext, MortgageApprovalApplication mortgageApprovalApplication)
        {
            Dictionary <long, double> interestDictionary = Interest.GetAll(maaContext);

            ViewBag.VBInterestList = interestDictionary;
            if (!interestDictionary.ContainsKey(mortgageApprovalApplication.InterestId))
            {
                return(View("Application"));
            }
            double interestRate = interestDictionary[mortgageApprovalApplication.InterestId];

            double monthlyPayment = Helper.CalculateMonthlyPayments(
                (double)mortgageApprovalApplication.LoanAmount,
                interestRate,
                mortgageApprovalApplication.TermOfLoan);

            if (mortgageApprovalApplication.MonthlyRepayment == Helper.Truncate2DecimalPoints((decimal)monthlyPayment))
            {
                //submit here
                maaContext.MortgageApprovalApplication.Add(mortgageApprovalApplication);
                maaContext.SaveChanges();
                //Reset model and set message
                mortgageApprovalApplication = new MortgageApprovalApplication
                {
                    Details =
                        $"Quote No {mortgageApprovalApplication.Id}   " +
                        $"(Value of Home = {mortgageApprovalApplication.ValueOfHome}; " +
                        $"Loan Amount = {mortgageApprovalApplication.LoanAmount}; " +
                        $"Term of Loan = {mortgageApprovalApplication.TermOfLoan}; " +
                        $"Interest on Loan = {interestRate}; " +
                        $"Monthly Repayment = {mortgageApprovalApplication.MonthlyRepayment})"
                };
                ModelState.Clear();
            }
            else
            {
                mortgageApprovalApplication.MonthlyRepayment = Helper.Truncate2DecimalPoints((decimal)monthlyPayment);
                mortgageApprovalApplication.Message          = "Monthly Repayment recalculated, please submit again";
            }

            return(View("Application", mortgageApprovalApplication));
        }
コード例 #5
0
        public IActionResult Calculate([FromServices] MaaContext maaContext, MortgageApprovalApplication mortgageApprovalApplication)
        {
            Dictionary <long, double> interestDictionary = Interest.GetAll(maaContext);

            ViewBag.VBInterestList = interestDictionary;
            if (!interestDictionary.ContainsKey(mortgageApprovalApplication.InterestId))
            {
                return(View("Application"));
            }
            double interestRate = interestDictionary[mortgageApprovalApplication.InterestId];

            double monthlyPayment = Helper.CalculateMonthlyPayments(
                (double)mortgageApprovalApplication.LoanAmount,
                interestRate,
                mortgageApprovalApplication.TermOfLoan);

            mortgageApprovalApplication.MonthlyRepayment = Helper.Truncate2DecimalPoints((decimal)monthlyPayment);

            return(View("Application", mortgageApprovalApplication));
        }
コード例 #6
0
 public IActionResult Application([FromServices] MaaContext maaContext)
 {
     ViewData["Message"]    = "Application";
     ViewBag.VBInterestList = Interest.GetAll(maaContext);
     return(View());
 }
コード例 #7
0
 public IActionResult Delete([FromServices] MaaContext maaContext, long id)
 {
     MortgageApprovalApplication.Delete(maaContext, id);
     //return List(maaContext);
     return(RedirectToAction("List", "Home"));
 }