Example #1
0
        public void TestSavePayment()
        {
            ISaver      saver       = new TextSaver();
            var         ctrl        = new WhatEverController(saver);
            PaymentInfo paymentInfo = new PaymentInfo
            {
                BSB           = "this is the bsb",
                AccountName   = "account name is here",
                AccountNumber = "what's the number",
                Reference     = "take reference"
            };

            paymentInfo = new PaymentInfo
            {
                BSB           = "123-456",
                AccountName   = "account name is here",
                AccountNumber = "1234567",
                Amount        = 1238
            };
            PaymentSaveResponse response = ctrl.SavePayment(paymentInfo);
            PaymentSaveResponse result   = new PaymentSaveResponse
            {
                Success = true
            };

            Assert.AreEqual(result.Success, response.Success);
        }
Example #2
0
        public PaymentSaveResponse SavePayment([FromForm] PaymentInfo paymentInfo)
        {
            log.Info("Enter SavePayment");
            PaymentSaveResponse psr = null;

            if (ModelState.IsValid)
            {
                log.Info("ModelState is valid, begin to save");
                var result = Saver.SavePaymentInfo(paymentInfo);

                psr = new PaymentSaveResponse
                {
                    Success = result.Success,
                    Errors  = result.Information
                };
            }
            else
            {
                log.Info("Model is NOT valid, return message.");
                psr = new PaymentSaveResponse
                {
                    Success = false,
                    Errors  = new List <string> {
                        "Invalid Fields"
                    }
                };
            }

            return(psr);
        }