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()); } }
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)); }