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

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