public virtual void ChangePayer(Payer payer) { var oldPayers = Payer; Payer = payer; foreach (var user in Users) { user.Payer.Users.Remove(user); user.Payer = payer; user.Payer.Users.Add(user); } payer.UpdatePaymentSum(); oldPayers.UpdatePaymentSum(); }
protected virtual void CommonChangePayer(Action changer, Payer payer) { var oldPayers = Payers.ToArray(); Payers.Clear(); Payers.Add(payer); foreach (var user in Users) { user.Payer.Users.Remove(user); user.Payer = payer; user.Payer.Users.Add(user); } changer(); payer.UpdatePaymentSum(); foreach (var oldPayer in oldPayers) { oldPayer.UpdatePaymentSum(); } }