Esempio n. 1
0
        /// <summary>
        /// Update the entity with the information current in the DataModel.
        /// </summary>
        /// <param name="entityRow">The entity row to base the update on.</param>
        public override void Update(EntityRow entityRow)
        {
            // HACK: CommissionSchedule should be in all blotters.
            DebtClassRow debtClassRow = DataModel.DebtClass.DebtClassKey.Find(entityRow.EntityId);

            base.Update(entityRow);

            if (!this.Modified && this.EntityId == entityRow.EntityId)
            {
                if (debtClassRow != null && debtClassRow.CommissionScheduleRow != null)
                {
                    if (this.commissionSchedule != null)
                    {
                        this.commissionSchedule.Update(debtClassRow.CommissionScheduleRow);
                    }
                    else
                    {
                        this.commissionSchedule = new CommissionSchedule(debtClassRow.CommissionScheduleRow);
                        this.commissionSchedule.PropertyChanged += this.OnCommissionScheduleChanged;
                    }
                }
                else if (this.commissionSchedule != null)
                {
                    this.commissionSchedule.PropertyChanged -= this.OnCommissionScheduleChanged;
                    this.commissionSchedule = null;
                }

                this.Modified = false;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Create a new commission schedule object based on another.
 /// </summary>
 /// <param name="commissionSchedule"></param>
 public CommissionSchedule(CommissionSchedule commissionSchedule)
 {
     this.commissionScheduleId = commissionSchedule.CommissionScheduleId;
     this.commissionTranches   = new ObservableCollection <CommissionTranche>();
     this.commissionTranches.CollectionChanged += this.OnCommissionTranchesChanged;
     this.Update(commissionSchedule);
 }
Esempio n. 3
0
 /// <summary>
 /// Create a duplicate blotter.
 /// </summary>
 /// <param name="source">The original blotter.</param>
 public Blotter(Blotter source) : base(source)
 {
     if (source.CommissionSchedule != null)
     {
         this.commissionSchedule = new CommissionSchedule(source.CommissionSchedule);
         this.commissionSchedule.PropertyChanged += this.OnCommissionScheduleChanged;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Update the schedule from another one.
        /// </summary>
        /// <param name="commissionSchedule">The source of updated information.</param>
        public void Update(CommissionSchedule commissionSchedule)
        {
            this.Name       = commissionSchedule.Name;
            this.rowVersion = commissionSchedule.RowVersion;

//			foreach (CommissionTranche commissionTranche in this.CommissionTranches)
//				commissionTranche.PropertyChanged -= this.OnCommissionTrancheChanged;
            this.CommissionTranches.Clear();

            foreach (CommissionTranche commissionTranche in commissionSchedule.CommissionTranches)
            {
//				commissionTranche.PropertyChanged += this.OnCommissionTrancheChanged;
                this.CommissionTranches.Add(commissionTranche);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Copy the contents of another entity into this one.
        /// </summary>
        /// <param name="entity">The source entity.</param>
        public override void Copy(GuardianObject entity)
        {
            base.Copy(entity);

            if ((entity as Blotter).CommissionSchedule != null)
            {
                if (this.CommissionSchedule == null)
                {
                    this.CommissionSchedule = new CommissionSchedule((entity as Blotter).CommissionSchedule);
                    this.CommissionSchedule.PropertyChanged += this.OnCommissionScheduleChanged;
                }
                else
                {
                    this.CommissionSchedule.Update((entity as Blotter).CommissionSchedule);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Update the entity from another entity.
        /// </summary>
        /// <param name="obj">The entity to base the update on.</param>
        public override void Update(GuardianObject obj)
        {
            base.Update(obj);

            Entity entity = obj as Entity;

            if (!this.Modified && this.EntityId == entity.EntityId)
            {
                if (this.CommissionSchedule == null)
                {
                    this.CommissionSchedule = new CommissionSchedule((entity as Blotter).CommissionSchedule);
                    this.CommissionSchedule.PropertyChanged += this.OnCommissionScheduleChanged;
                }
                else
                {
                    this.CommissionSchedule.Update((entity as Blotter).CommissionSchedule);
                }

                this.Modified = false;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Retrieve the commission schedule in use for this blotter, whether or not the schedule is set at this level in the tree. This function locks the data model.
        /// </summary>
        /// <param name="blotterId">The blotter id of the blotter.</param>
        /// <returns>The commission schedule, or a new one if none could be found.</returns>
        public static CommissionSchedule GetEffectiveCommissionSchedule(Guid blotterId)
        {
            CommissionSchedule commissionSchedule = null;

            lock (DataModel.SyncRoot)
            {
                // HACK: The commission schedule is keyed to the debt class right now, but should change to Blotter.
                Guid?commissionScheduleId = (Guid?)Blotter.FindEffectiveField <Guid>(blotterId, DataModel.DebtClass.CommissionScheduleIdColumn);

                if (commissionScheduleId != null)
                {
                    commissionSchedule = new CommissionSchedule(
                        DataModel.CommissionSchedule.CommissionScheduleKey.Find(commissionScheduleId.Value));
                }
                else
                {
                    commissionSchedule = new CommissionSchedule();
                }
            }

            return(commissionSchedule);
        }