public Debt PayDebt(PayDebtDTO payDebt) { Debt debt = this._billRepository.FindDebt(payDebt.idDebt); if (debt == null) { throw new APIException("the debt could not be found", StatusCodes.Status404NotFound); } this._accountService.TransferAccounts(payDebt.idAccountSource, payDebt.idAccountDestination, payDebt.sumToPay); debt.Payed = true; this.UpdateDebt(debt); return(debt); }
public IActionResult PayDebt([FromBody] PayDebtDTO payDebt) { if (!ModelState.IsValid) { return(StatusCode(400, "bad data!")); } try { var debt = this._billService.PayDebt(payDebt); return(Ok(debt)); } catch (APIException ex) { ErrorMessage err = new ErrorMessage { message = ex.Message }; return(StatusCode(ex.StatusCode, err)); } }