public async Task <ApiResponseDto <bool> > DeleteTransaction(long transactionId, bool isAdmin) { var transaction = await _transRepo.FindTransactionById(transactionId); if (transaction == null) { return(new ApiResponseDto <bool>(404, "Transaction record not found", "Eror deleting record", false)); } if (transaction.HasPaid && !transaction.Delivered && !isAdmin) { return(new ApiResponseDto <bool>(403, "Transaction already paid for but not delivered cannot be deleted, please contact the admin for any issue related to this transaction", "Eror deleting record", false)); } _transRepo.DeleteTransaction(transaction); var isDeleted = await _transRepo.SaveChanges(); if (!isDeleted) { return(new ApiResponseDto <bool>(500, "We encoured a problem while trying to delete this record", "Error deleting record", false)); } return(new ApiResponseDto <bool>(200, "Record deleted successfully", null, true)); }
/// <summary> /// if transaction is successfull but there is problem with accounts it delete last transaction /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="sum"></param> /// <param name="category"></param> /// <param name="VS"></param> /// <param name="CS"></param> /// <param name="SS"></param> /// <param name="MessageForReceiver"></param> /// <returns>returns statement how did the trasaction go</returns> public String CreateTransaction(int from, int to, decimal sum, string category, string VS, string CS, string SS, string MessageForReceiver) { string ret; int transactionId = _transactionsRepository.InsertTransaction(from, to, sum, category); if (transactionId > 0) { _bankAccountRepository.UpdatebankAccountFrom(transactionId, sum); _bankAccountRepository.UpdatebankAccountTo(transactionId, sum); if (!VS.Equals(string.Empty)) { _transactionsRepository.UpdateMessage("VS", transactionId, VS); } if (!CS.Equals(string.Empty)) { _transactionsRepository.UpdateMessage("CS", transactionId, CS); } if (!SS.Equals(string.Empty)) { _transactionsRepository.UpdateMessage("SS", transactionId, SS); } if (!MessageForReceiver.Equals(string.Empty)) { _transactionsRepository.UpdateMessage("MessageForReceiver", transactionId, MessageForReceiver); } ret = "Transaction was sucssessfull"; } else { _transactionsRepository.DeleteTransaction(transactionId); ret = "Transaction was unsucssessfull"; } return(ret); }
public ActionResult Delete(string settlementId, Guid transactionId) { _transactionsRepository.DeleteTransaction(settlementId, transactionId); return(Ok()); }