Example #1
0
        ///<summary>
        /// Adds the doctorcommissionhistory.
        /// </summary>
        /// <param name="doctorcommissionhistory">The doctorcommissionhistory.</param>
        public void AddDoctorCommissionHistory(DoctorCommissionHistory commissionHistory)
        {
            if (DoctorCommissionHistories == null)
            {
                DoctorCommissionHistories = new List <DoctorCommissionHistory>();
            }

            // set this one as latest.
            commissionHistory.IsLatest = true;

            // If this is the new latest commissionhistory.
            if (commissionHistory.IsLatest)
            {
                foreach (DoctorCommissionHistory history in DoctorCommissionHistories)
                {
                    history.IsLatest = false;
                }
            }

            // If the commissionhistory is not already in the list
            if (!DoctorCommissionHistories.Any(x => x.PrimaryKey == commissionHistory.PrimaryKey))
            {
                DoctorCommissionHistories.Add(commissionHistory);
                commissionHistory.Doctor = this;
            }
        }
Example #2
0
        ///<summary>
        /// Removes the doctorcommissionhistory.
        /// </summary>
        /// <param name="doctorcommissionhistory">The doctorcommissionhistory.</param>
        public void RemoveDoctorCommissionHistory(DoctorCommissionHistory commissionHistory)
        {
            if (DoctorCommissionHistories == null)
            {
                return;
            }

            DoctorCommissionHistories.Remove(commissionHistory);

            if (commissionHistory.IsLatest)
            {
                DoctorCommissionHistories.LastOrDefault().IsLatest = true;
            }
        }