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); }