Exemple #1
0
        public ActionResult Withdraw(WithdrawAmountModel 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
                    {
                        if (model.Status == true)
                        {
                            t.Withdraw(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));
        }
Exemple #2
0
        public void Withdraw(WithdrawAmountModel model)
        {
            //TODO: - showcase state based testing + mock verification

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

            // take money out
            account.Withdraw(model.Amount);

            //save the account to DB
            _db.SaveChanges();

            //call notifyService with the event
            _notificationService.MoneyWithdrawn(account.Iban, account.Balance);
        }
 public void Withdraw(WithdrawAmountModel model)
 {
     new WithDrawCommandHandler(_db, _notificationService).Withdraw(model);
 }