/// <summary> /// Create a new commission schedule object from a commission schedule row. /// </summary> /// <param name="commissionScheduleRow"></param> public CommissionSchedule(CommissionScheduleRow commissionScheduleRow) { this.commissionScheduleId = commissionScheduleRow.CommissionScheduleId; this.commissionTranches = new ObservableCollection <CommissionTranche>(); this.commissionTranches.CollectionChanged += this.OnCommissionTranchesChanged; this.Update(commissionScheduleRow); }
/// <summary> /// Update the schedule from another one. /// </summary> /// <param name="commissionSchedule">The source of updated information.</param> public void Update(CommissionScheduleRow commissionSchedule) { this.Name = commissionSchedule.IsNameNull()? null : commissionSchedule.Name; this.rowVersion = commissionSchedule.RowVersion; // foreach (CommissionTranche commissionTranche in this.CommissionTranches) // commissionTranche.PropertyChanged -= this.OnCommissionTrancheChanged; this.CommissionTranches.Clear(); foreach (CommissionTrancheRow commissionTrancheRow in commissionSchedule.GetCommissionTrancheRows()) { CommissionTranche commissionTranche = new CommissionTranche(commissionTrancheRow); // commissionTranche.PropertyChanged += this.OnCommissionTrancheChanged; this.CommissionTranches.Add(commissionTranche); } }