///<summary>Takes a list of fees to be deleted and deletes them from rest of the clinics in the feeschedgroup.</summary> public static void DeleteGroupFees(List <Fee> listFees) { //No need to check RemotingRole; no call to db. List <long> listFeeNumsToDelete = new List <long>(); foreach (Fee feeCur in listFees) { FeeSchedGroup groupCur = GetOneForFeeSchedAndClinic(feeCur.FeeSched, feeCur.ClinicNum); if (groupCur == null) { continue; } //Go through the clinics in the group and delete the fee. foreach (long clinicNum in groupCur.ListClinicNumsAll) { //Skip fees passed into this method, they will be deleted elsewhere by FeeCrud if (clinicNum == feeCur.ClinicNum) { continue; } Fee feeToDelete = Fees.GetFeeFromDb(feeCur.CodeNum, feeCur.FeeSched, clinicNum, feeCur.ProvNum, true); if (feeToDelete != null) { listFeeNumsToDelete.Add(feeToDelete.FeeNum); } } } Fees.DeleteMany(listFeeNumsToDelete, false); }
///<summary>This method Upserts copies of the supplied fee for every clinic in the list. Matches fees based on FeeSched, CodeNum, and ProvNum.</summary> public static void CopyFeeAmountToGroup(Fee fee, List <long> listClinicNums) { //No need to check RemotingRole; no call to db. List <Fee> listFeesInsert = new List <Fee>(); foreach (long clinicNum in listClinicNums) { //Skip the passed in fee if it was included in the list. It is assumed to be handled by FeeCrud if (clinicNum == fee.ClinicNum) { continue; } Fee feeToChange = Fees.GetFeeFromDb(fee.CodeNum, fee.FeeSched, clinicNum, fee.ProvNum, true); //Couldn't find the fee in the Db, insert it. if (feeToChange == null) { Fee newFee = new Fee() { Amount = fee.Amount, FeeSched = fee.FeeSched, CodeNum = fee.CodeNum, ClinicNum = clinicNum, ProvNum = fee.ProvNum, }; listFeesInsert.Add(newFee); continue; } //Found the fee, make it match the passed in fee. All of these values are required to match to keep the group in sync. feeToChange.Amount = fee.Amount; feeToChange.FeeSched = fee.FeeSched; feeToChange.CodeNum = fee.CodeNum; feeToChange.ProvNum = fee.ProvNum; //Don't call FeeSchedGroup logic or we'll be sucked into an infinite void. Fees.Update(feeToChange, false); } if (listFeesInsert.Count > 0) { //Don't call FeeSchedGroup logic or we'll be sucked into an infinite void. Fees.InsertMany(listFeesInsert, false); } }