internal string Delete(int id, string userId) { Transaction foundTransaction = _repo.GetById(id, userId); if (foundTransaction.UserId != userId) { throw new Exception("That is not your transaction"); } if (_repo.Delete(id, userId)) { return("Transaction Deleted"); } throw new Exception("Something went wrong"); }
public ActionResult Delete(int transactionId) { try { _transactionsRepository.Delete(transactionId); _transactionsRepository.SaveChanges(); } catch (Exception ex) { return(BadRequest(_translationService.TranslateException(ex, Request.Headers))); } return(Ok(transactionId)); }