Example #1
0
        public void ChangeTopicCode(TopicCode topicCode)
        {
            if (_topicCodeId == default(Guid) && topicCode == null)
                return;

            if (topicCode == null)
            {
                ApplyEvent(new SectionTopicCodeRemovedEvent(EventSourceId));
                return;
            }

            var topicCodeData = topicCode.BuildMemento();

            if (_topicCodeId == topicCodeData.Id)
                return;

            ApplyEvent(new SectionTopicCodeChangedEvent(
                           EventSourceId,
                           topicCodeData.Id,
                           topicCodeData.Abbreviation,
                           topicCodeData.Description));
        }
Example #2
0
        public void ChangeLocation(Location location, TopicCode tdcjTopicCode)
        {
            if (tdcjTopicCode == null)
                throw new InvalidStateException("You did not supply the TDCJ topic code.");

            if (tdcjTopicCode.BuildMemento().Abbreviation != "A")
                throw new InvalidStateException(
                    "You supplied the wrong TDCJ topic code. The TDCJ topic code abbreviation is \"A\"");

            var locationData = location.BuildMemento();

            if (locationData.LocationId == _locationId)
                return;

            ApplyEvent(new SectionLocationChangedEvent(
                           EventSourceId,
                           locationData.LocationId,
                           locationData.Abbreviation,
                           locationData.Name));

            if (_isCredit)
                switch (locationData.Abbreviation)
                {
                    case "CLEM":
                    case "CV":
                    case "DAR":
                    case "J1":
                    case "J2":
                    case "J3":
                    case "R1":
                    case "R2":
                    case "TER":
                        ChangeTopicCode(tdcjTopicCode);
                        break;
                    default:
                        ChangeTopicCode(null);
                        break;
                }
        }