Exemplo n.º 1
0
        public Transaction RemoveTempAndReturnTransaction(IConnectionHandler connectionHandler, Guid tempId)
        {
            var tre = this.Get(connectionHandler, tempId);

            if (tre == null || !tre.TransactionId.HasValue)
            {
                return(null);
            }
            var transaction = new TransactionBO().Get(connectionHandler, tre.TransactionId);
            var allowdelete = true;

            if (transaction != null)
            {
                if (transaction.PayTypeId == (byte)Enums.PayType.OnlinePay && !transaction.Done)
                {
                    allowdelete = false;
                }
            }
            if (!allowdelete)
            {
                return(transaction);
            }
            if (!this.Delete(connectionHandler, tre))
            {
                throw new Exception(Resources.Payment.ErrorInDeleteTemp);
            }
            return(transaction);
        }
Exemplo n.º 2
0
        public Transaction InsertTransactionFromTemp(IConnectionHandler connectionHandler, Temp temp, Transaction newtransaction, byte paytype)
        {
            var bo          = new TransactionBO();
            var orderId     = bo.Max(connectionHandler, x => x.InvoiceId) + 1;
            var transaction = new Transaction
            {
                Amount            = temp.Amount,
                PayTypeId         = paytype,
                InvoiceId         = orderId,
                Status            = null,
                Description       = temp.Description,
                PayerId           = temp.PayerId,
                PayerTitle        = temp.PayerTitle,
                CallBackUrl       = temp.CallBackUrl,
                CurrencyType      = temp.CurrencyType,
                AdditionalData    = temp.AdditionalData,
                TrackYourOrderNum = temp.TrackYourOrderNum
            };

            if (newtransaction != null)
            {
                transaction.DocNo        = newtransaction.DocNo;
                transaction.PayDate      = newtransaction.PayDate;
                transaction.DocScan      = newtransaction.DocScan;
                transaction.AccountId    = newtransaction.AccountId;
                transaction.OnlineBankId = newtransaction.OnlineBankId;
            }

            if (!ValidateTransaction(transaction))
            {
                return(null);
            }
            if (!this.Insert(connectionHandler, transaction))
            {
                throw new Exception(Resources.Payment.ErrorInSaveTransaction);
            }
            var transactionDiscountBo = new TransactionDiscountBO();
            var discountAttaches      = new TempDiscountBO().Where(connectionHandler, discount => discount.TempId == temp.Id);

            foreach (var discountAttach in discountAttaches)
            {
                if (discountAttaches.Count > 1)
                {
                    System.Threading.Thread.Sleep(1000);
                }
                var transactionDiscount = new TransactionDiscount
                {
                    TransactionId  = transaction.Id,
                    DiscountTypeId = discountAttach.DiscountTypeId,
                    AttachId       = discountAttach.AttachId
                };
                if (!transactionDiscountBo.Insert(connectionHandler, transactionDiscount))
                {
                    throw new Exception(Resources.Payment.ErrorInSaveTransactionDiscount);
                }
            }
            return(transaction);
        }