public IActionResult DepositAmount(DepositAmountModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _bankAccountApplicationService.Deposit(model);

            return(Ok());
        }
        public void Deposit(DepositAmountModel model)
        {
            //TODO: - showcase simple state based testing on domain model

            //get the account
            var account = _db.Accounts.Find(model.AccountId);

            // use deposit method
            account.Deposit(model.Amount);

            //save the account to DB
            _db.SaveChanges();
        }
Exemple #3
0
        public ActionResult Deposit(DepositAmountModel model)
        {
            string card    = (string)Session["CardNumber"];
            string account = (string)Session["Account"];

            var temp = security.GetBankAccounts(card);

            foreach (BankAccount t in temp)
            {
                if (t.AccountName == account)
                {
                    try
                    {
                        t.Deposit(model.Amount);
                        return(Json(new { withdrew = "everything went well", reply = true, balance = t.Balance, name = account }, JsonRequestBehavior.AllowGet));
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        return(Json(new { withdrew = e.Message, reply = false, balance = t.Balance, name = account }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json(new { withdrew = "something bad happened", reply = false }, JsonRequestBehavior.AllowGet));
        }
        //commands

        public void Deposit(DepositAmountModel model)
        {
            new DepositCommandHandler(_db).Deposit(model);
        }