コード例 #1
0
        public IActionResult ConfirmRefundConfirmed(string id)
        {
            try
            {
                var refund = _refundService.List().Single(x => x.RefundId == id);
                if (refund == null)
                {
                    return(RedirectToAction("Refund", "Loans", new { id = id }));
                }
                var lastCustomerConfirmedTransaction = _refundService.CustomerLastConfirmedTransaction(refund);

                refund.Balance    = lastCustomerConfirmedTransaction.Balance - refund.Amount;
                refund.StatusCode = (refund.Amount == refund.Balance)? Data.Enums.StatusCode.Settled: Data.Enums.StatusCode.Confirmed;
                _refundService.Update(refund);


                _refundconfirmService.Create(new RefundConfirmModel()
                {
                    RefundId   = id,
                    EmployeeId = GetEmployeeId().Result,
                    CustomerId = refund.CustomerId
                });

                return(RedirectToAction("Refund", "Loans", new { id = refund.LoanId }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message + " " + ex.InnerException);
            }

            return(RedirectToAction("Index"));
        }