public IActionResult PostWalletTransaction(TransactionRequest request) { TransactionResponse response = new TransactionResponse(); try { response = TransactionAccess.AddTransaction(request); if (response.ErrorCode == MyJijoWalletData.ErrorCode.NoError) { return(Ok(response)); } if (response.ErrorCode == MyJijoWalletData.ErrorCode.Validation) { return(BadRequest(response)); } else { throw new Exception(response.ErrorMessage); } } catch (Exception ex) { response.ErrorCode = MyJijoWalletData.ErrorCode.Other; response.ErrorMessage = ex.Message; return(StatusCode(StatusCodes.Status500InternalServerError, response)); } }
public void AddTransactionShouldSucceed() { TransactionRequest request; request = new TransactionRequest(); request.Amount = (new Random()).Next(0, 1000000); request.Client = Guid.Parse("8920d0ff-4d19-4a3f-8d11-63c0ceb39923"); request.TransactionCode = "ATMDEB"; request.Wallet = Guid.Parse("8920d0ff-4d19-4a3f-8d11-63c0ceb39922"); TransactionResponse response = TransactionAccess.AddTransaction(request); Assert.IsTrue(response.ErrorCode == 0); }
public void AddTransactionShouldFail() { TransactionRequest request; request = new TransactionRequest(); request.Client = new Guid(); request.Amount = (new Random()).Next(0, 1000000); request.TransactionCode = "ATMDEB"; request.Wallet = new Guid(); TransactionResponse response = TransactionAccess.AddTransaction(request); Assert.IsFalse(response.ErrorCode == 0); }