public int AddPaymentRefundRecord(DLModel.PaymentRefund modelPaymentRefund)
        {
            DLModel.Invoice InvoiceDetail = _IInvoiceImpl.GetInvoiceDetailsById(modelPaymentRefund.InvoiceId);
            InvoiceDetail.InvoiceBalanceAmt = (InvoiceDetail.InvoiceBalanceAmt + modelPaymentRefund.RefundAmount).Value;
            var updInvoiceBalAmt = _invoiceRepository.Update(InvoiceDetail, inv => inv.InvoiceBalanceAmt);

            return(_paymentRefundRepository.Add((DLModel.PaymentRefund) new DLModel.PaymentRefund().InjectFrom(modelPaymentRefund)).PaymentRefundID);
        }
        public int UpdatePaymentRefundRecord(DLModel.PaymentRefund modelPaymentRefund)
        {
            DLModel.Invoice InvoiceDetail    = _IInvoiceImpl.GetInvoiceDetailsById(modelPaymentRefund.InvoiceId);
            var             oldPaymentAmount = _paymentRefundRepository.GetAll(pay => pay.PaymentRefundID == modelPaymentRefund.PaymentRefundID).Select(inv => new DLModel.PaymentRefund().InjectFrom(inv)).Cast <DLModel.PaymentRefund>().SingleOrDefault().RefundAmount;
            var             newInvoiceAmount = (InvoiceDetail.InvoiceBalanceAmt - oldPaymentAmount) + modelPaymentRefund.RefundAmount;

            InvoiceDetail.InvoiceBalanceAmt = newInvoiceAmount.Value;
            var updInvoiceBalAmt = _invoiceRepository.Update(InvoiceDetail, inv => inv.InvoiceBalanceAmt);

            return(_paymentRefundRepository.Update((DLModel.PaymentRefund) new DLModel.PaymentRefund().InjectFrom(modelPaymentRefund)));
        }