Пример #1
0
        public void UpdateNomineeEmailAddress(Person nominee, EmailAddress newEmailAddress)
        {
            if (nominee == null)
            {
                throw new ArgumentNullException(nameof(nominee));
            }
            if (newEmailAddress == null)
            {
                throw new ArgumentNullException(nameof(newEmailAddress));
            }
            if (!newEmailAddress.IsValid)
            {
                throw new ArgumentException(nameof(newEmailAddress));
            }

            if (nominee.EmailAddress == newEmailAddress)
            {
                return;
            }

            var nominations = Nominations.Where(n => n.Nominee == nominee);
            var updated     = false;

            foreach (var nomination in nominations)
            {
                nomination.UpdateNomineeEmailAddress(newEmailAddress);
                updated = true;
            }

            if (!updated)
            {
                return;
            }

            SetNomineeIdentifiers();

            var awardWinner = AwardWinners.FirstOrDefault(w => w.Person == nominee);

            if (awardWinner != null)
            {
                awardWinner.UpdateAwardWinnerEmailAddress(newEmailAddress);
            }

            MarkAsDirty($@"Updated nominee email address from {nominee.EmailAddress.Value} to {newEmailAddress.Value}");
        }
Пример #2
0
        public void UpdateNomineeName(Person nominee, PersonName newNomineeName)
        {
            if (nominee == null)
            {
                throw new ArgumentNullException(nameof(nominee));
            }
            if (newNomineeName == null)
            {
                throw new ArgumentNullException(nameof(newNomineeName));
            }
            if (!newNomineeName.IsValid)
            {
                throw new ArgumentException(nameof(newNomineeName));
            }

            if (nominee.Name == newNomineeName)
            {
                return;
            }

            var nominations = Nominations.Where(n => n.Nominee == nominee);
            var updated     = false;

            foreach (var nomination in nominations)
            {
                nomination.UpdateNomineeName(newNomineeName);
                updated = true;
            }

            if (!updated)
            {
                return;
            }

            SetNomineeIdentifiers();

            var awardWinner = AwardWinners.FirstOrDefault(w => w.Person == nominee);

            if (awardWinner != null)
            {
                awardWinner.UpdateAwardWinnerName(newNomineeName);
            }

            MarkAsDirty($@"Updated nominee name from {nominee.Name.FullName} to {newNomineeName.FullName}");
        }
Пример #3
0
        public void UpdateNomineeOfficeLocation(Person nominee, OfficeLocation newOfficeLocation)
        {
            if (nominee == null)
            {
                throw new ArgumentNullException(nameof(nominee));
            }
            if (newOfficeLocation == null)
            {
                throw new ArgumentNullException(nameof(newOfficeLocation));
            }
            if (!OfficeLocation.ValidEmployeeOfficeLocations.Contains(newOfficeLocation))
            {
                throw new ArgumentException(nameof(newOfficeLocation));
            }

            var nominations = Nominations.Where(n => n.Nominee == nominee);
            var updated     = false;

            foreach (var nomination in nominations)
            {
                nomination.UpdateNomineeOfficeLocation(newOfficeLocation);
                updated = true;
            }

            if (!updated)
            {
                return;
            }

            SetNomineeIdentifiers();

            var awardWinner = AwardWinners.FirstOrDefault(w => w.Person == nominee);

            if (awardWinner != null)
            {
                awardWinner.UpdateAwardWinnerOfficeLocation(newOfficeLocation);
            }

            MarkAsDirty(
                $@"Updated nominee {nominee.Name.FullName}'s office location from {nominee.OfficeLocation.Name} to {
                        newOfficeLocation.Name
                    }");
        }