示例#1
0
        public async Task <IActionResult> RevertTransaction([FromBody] RevertTransactionViewModel transaction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model is not valid"));
            }

            try
            {
                if (await _paymentService.RevertTransaction(transaction))
                {
                    return(Accepted());
                }
                return(NotFound());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(BadRequest("Something went wrong, try again in a minute"));
            }
        }
示例#2
0
        public async Task <bool> RevertTransaction(RevertTransactionViewModel transaction)
        {
            var buyerTransaction = await _accountsService.RevertTransaction(transaction.BuyerAccountId, transaction.BuyerTransactionId);

            var sellerTransaction = await _accountsService.RevertTransaction(transaction.SellerAccountId, transaction.SellerTransactionId);

            if (buyerTransaction == null || sellerTransaction == null)
            {
                if (buyerTransaction != null)
                {
                    await _accountsService.RevertTransaction(transaction.BuyerAccountId,
                                                             buyerTransaction.TransactionId);
                }
                if (sellerTransaction != null)
                {
                    await _accountsService.RevertTransaction(transaction.SellerAccountId,
                                                             sellerTransaction.TransactionId);
                }

                return(false);
            }
            return(true);
        }