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); }
public override bool Delete(IConnectionHandler connectionHandler, Temp obj) { if (obj == null) { return(true); } var tempDiscountBo = new TempDiscountBO(); var tempdiscount = tempDiscountBo.Where(connectionHandler, discount => discount.TempId == obj.Id); foreach (var tempDiscount in tempdiscount) { if (!tempDiscountBo.Delete(connectionHandler, tempDiscount)) { throw new Exception(Resources.Payment.ErrorInDeleteDiscount); } } return(base.Delete(connectionHandler, obj)); }
public bool GroupPayTemp(IConnectionHandler connectionHandler, Temp temp, List <Guid> model) { temp.Description = Resources.Payment.GroupPayment + " "; var index = 1; foreach (var guid in model) { if (temp.Description.Length > 80) { temp.Description += "\r\n" + " "; } var temp1 = this.Get(connectionHandler, guid); if (temp1 == null) { continue; } temp.Amount += temp1.Amount; temp.Description += ((index > 1 && index <= model.Count) ? " " + Resources.Payment.And + " " : " ") + temp1.Description + " " + Resources.Payment.WithAmount + ":" + temp1.Amount + " " + ((Common.Definition.Enums.CurrencyType)temp1.CurrencyType) .GetDescriptionInLocalization(); index++; } if (!this.Insert(connectionHandler, temp)) { return(false); } if (!model.Any()) { return(true); } var list = this.Where(connectionHandler, x => x.Id.In(model)); var tempDiscountBo = new TempDiscountBO(); var discounts = tempDiscountBo.Where(connectionHandler, x => x.TempId.In(model)); foreach (var temp1 in list) { if (model.Count > 1) { System.Threading.Thread.Sleep(1000); } temp1.ParentId = temp.Id; if (!this.Update(connectionHandler, temp1)) { return(false); } var discountAttaches = discounts.Where(discount => discount.TempId == temp1.Id).ToList(); foreach (var discountAttach in discountAttaches) { if (discountAttaches.Count > 1) { System.Threading.Thread.Sleep(1000); } var tempDiscount = new TempDiscount() { TempId = temp.Id, DiscountTypeId = discountAttach.DiscountTypeId, AttachId = discountAttach.AttachId }; if (!tempDiscountBo.Insert(connectionHandler, tempDiscount)) { throw new Exception(Resources.Payment.ErrorInSaveTransactionDiscount); } } } return(true); }