Exemple #1
0
        public Member GotMarried(DateTime since, Member partner = null)
        {
            if (WasMarried(since))
            {
                throw new HistoryViolationException("Member was already married that time.");
            }

            if (HadPartner(since))
            {
                if (!HadPartner(since, partner))
                {
                    throw new HistoryViolationException("Trying to get married with another partner.");
                }
            }
            else if (partner == null)
            {
                throw new HistoryViolationException("Trying to get married with no partner.");
            }
            else
            {
                WithPartner(partner, since);
            }

            Status.AddChange(StatusOptions.Married, since);

            if (Refs.TryGetPartner(out Member value, since))
            {
                value.Status.AddChange(StatusOptions.Married, since);
            }
            return(this);
        }
Exemple #2
0
        public Member(
            string birthFullName, DateTime birthDate
            ) : base(birthFullName, birthDate)
        {
            Initialize();

            Status.AddChange(StatusOptions.Unmarried, BirthDate);
            FullName.AddChange(birthFullName, BirthDate);
            Refs = new References(this);
        }
Exemple #3
0
        public Member WithoutPartner(DateTime since)
        {
            if (!HadPartner(since))
            {
                throw new HistoryViolationException("Trying to break up with the partner that was not set that time.");
            }

            if (WasMarried(since))
            {
                Status.AddChange(StatusOptions.Unmarried, since);

                if (Refs.TryGetPartner(out Member partner, since))
                {
                    partner.Status.AddChange(StatusOptions.Unmarried, since);
                }
            }

            return(SetPartner(null, since));
        }