public static void SetFactured(List <LifePolicyBrokerage> paymentList, Facture f, List <LifePolicy> policiesToRemove) { List <LifePolicyBrokerage> notForSetting = new List <LifePolicyBrokerage>(); foreach (LifePolicy pi in policiesToRemove) { notForSetting.AddRange(LifePolicyBrokerage.GetByLifePolicy(pi.ID)); } List <LifePolicyBrokerage> validPaymentList = new List <LifePolicyBrokerage>(); foreach (LifePolicyBrokerage p in paymentList) { if (!notForSetting.Contains(p)) { validPaymentList.Add(p); } } foreach (LifePolicyBrokerage p in validPaymentList) { p.IsFactured = true; p.Update2(); //Context.SubmitChanges(); FacturePayment fp = new FacturePayment(); fp.PaymentID = p.ID; fp.FactureID = f.ID; fp.PaymentTypeID = PaymentType.GetByCode(PaymentType.FACTURE).ID; fp.Insert(); } }
public static void SetFactured(List <Payment> paymentList, Facture f) { foreach (Payment p in paymentList) { p.IsFactured = true; FacturePayment fp = new FacturePayment(); fp.PaymentID = p.ID; fp.FactureID = f.ID; fp.PaymentTypeID = PaymentType.GetByCode(PaymentType.FACTURE).ID; fp.Insert(); } }