Esempio n. 1
0
        public void DoAccountWithdraw(uint accountID, [FromBody] uint amount)
        {
            try
            {
                access.SelectAccount(accountID);
            }
            catch (Exception)
            {
                var response = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content      = new StringContent("Could not perform withdrawal from account"),
                    ReasonPhrase = "Account could not be found"
                };
                throw new HttpResponseException(response);
            }

            try
            {
                access.Withdraw(amount);
            }
            catch (Exception)
            {
                var response = new HttpResponseMessage(HttpStatusCode.Forbidden)
                {
                    Content      = new StringContent("Could not perform withdrawal from account"),
                    ReasonPhrase = "Account has insufficient funds"
                };
                throw new HttpResponseException(response);
            }
        }
Esempio n. 2
0
 public void Withdraw(uint amount)
 {
     accountAccess.Withdraw(amount);
     bankDb.SaveToDisk();
 }
Esempio n. 3
0
 public void Withdraw(uint amount)
 {
     accountAccess.Withdraw(amount);
 }