Beispiel #1
0
        public IActionResult Create([Bind("Id,Balance,Start_date,End_date,Interest,Exist,UserId")] Loan loan)
        {
            if (loan.Balance <= 0)
            {
                ViewData["error"] = "Invaild input";
                return(View(loan));
            }
            //default setting for new checking account
            loan.Start_date = DateTime.Today;
            loan.End_date   = DateTime.Today.AddDays(1);
            loan.Exist      = true;
            //random interest for overdraft

            loan.Interest = (decimal)Math.Round((new Random().NextDouble() * (0.9 - 0.1) + 0.1) / 10, 3);
            loan.Balance *= (1 + loan.Interest);
            DAL.CreateLoan(loan);
            return(RedirectToAction(nameof(Index)));
        }