Ejemplo n.º 1
0
        public async Task <ActionResult> Withdraw(int requestedAmount)
        {
            try
            {
                if (requestedAmount < 0)
                {
                    throw new InvalidAtmOperationException($"You may not withdraw negative amounts. Requested amount: {requestedAmount}");
                }

                var response = await _denomService.Withdraw(requestedAmount);

                return(Ok(response));
            }
            catch (InvalidAtmOperationException iaoe)
            {
                return(BadRequest(iaoe.Message));
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Withdraw(int requestedAmount)
        {
            try
            {
                if (requestedAmount < 0)
                {
                    throw new InvalidAtmOperationException($"You may not withdraw negative amounts. Requested amount: {requestedAmount}");
                }

                var history = _denomService.Withdraw(requestedAmount);

                return(Ok(FormatTransaction(history)));
            }
            catch (InvalidAtmOperationException iaoe)
            {
                return(BadRequest(iaoe.Message));
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }