public TransactionDetailStruct CreateTransaction([FromBody] TransactionDetailStruct newTransaction) { if (newTransaction.amount < 0) { var response = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("Could not create new transaction"), ReasonPhrase = "Transaction amount cannot be less than 0" }; throw new HttpResponseException(response); } if (newTransaction.receiverID == newTransaction.senderID) { var response = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("Could not create new transaction"), ReasonPhrase = "Sender and Receiver ID cannot be the same" }; throw new HttpResponseException(response); } TransactionDetailStruct result = new TransactionDetailStruct(); result.transactionID = access.CreateTransaction(); access.SelectTransaction(result.transactionID); access.SetSendr(newTransaction.senderID); access.SetRecvr(newTransaction.receiverID); access.SetAmount(newTransaction.amount); result.senderID = access.GetSendrAcct(); result.receiverID = access.GetRecvrAcct(); result.amount = access.GetAmount(); return(result); }
public void SetSendr(uint acctID) { transactionAccess.SetSendr(acctID); }