예제 #1
0
        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));
            }
        }
예제 #2
0
        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);
        }
예제 #3
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);
        }