Esempio n. 1
0
        public IActionResult Withdraw(string id, [FromBody] AmountViewModel model)
        {
            try
            {
                var atm = _atmRepository.GetATM(id);

                if (atm == null)
                {
                    return(new NotFoundResult());
                }

                atm.TakeMoney(model.Amount);

                return(Ok(_atmRepository.UpdateATM(atm)));
            }
            catch
            {
                return(new BadRequestResult());
            }
        }
Esempio n. 2
0
        public ActionResult <ATMResponse> UpdateATM(int id, ATMUpdateRequest request)
        {
            var ATMToUpdate = _ATMRepository.FindATMResponseById(id);

            if (ATMToUpdate == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var result = _ATMRepository.UpdateATM(id, request);

            return(Ok(result));
        }