Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Agency"/> class.
        /// </summary>
        /// <param name="agencyProfile">
        /// The agency profile.
        /// </param>
        /// <param name="parentAgency">
        /// The parent agency.
        /// </param>
        protected internal Agency(AgencyProfile agencyProfile, Agency parentAgency)
            : this()
        {
            Check.IsNotNull(agencyProfile, () => AgencyProfile);

            _agencyProfile = agencyProfile;
            _parentAgency  = parentAgency;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the agency.
        /// </summary>
        /// <param name="agencyProfile">
        /// The agency profile.
        /// </param>
        /// <returns>
        /// An Agency.
        /// </returns>
        public Agency CreateAgency(AgencyProfile agencyProfile)
        {
            Check.IsNotNull(agencyProfile, "agencyProfile is required.");

            Agency agency = new AgencyBuilder().WithAgencyProfile(agencyProfile);

            _agencyRepository.MakePersistent(agency);

            return(agency);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the child agency.
        /// </summary>
        /// <param name="agencyProfile">
        /// The agency profile.
        /// </param>
        /// <param name="parentAgency">
        /// The parent agency.
        /// </param>
        /// <returns>
        /// An Agency.
        /// </returns>
        public Agency CreateChildAgency(AgencyProfile agencyProfile, Agency parentAgency)
        {
            Check.IsNotNull(agencyProfile, "agencyProfile is required.");
            Check.IsNotNull(parentAgency, "parentAgency is required.");

            Agency agency = new AgencyBuilder().WithAgencyProfile(agencyProfile).WithPatentAgency(parentAgency);

            _agencyRepository.MakePersistent(agency);

            return(agency);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Revises the agency profile.
        /// </summary>
        /// <param name="agencyProfile">
        /// The agency profile.
        /// </param>
        public virtual void ReviseAgencyProfile(AgencyProfile agencyProfile)
        {
            Check.IsNotNull(agencyProfile, () => AgencyProfile);

            if (AgencyProfile == agencyProfile)
            {
                return;
            }

            AgencyProfile oldAgencyProfile = AgencyProfile;

            AgencyProfile = agencyProfile;

            DomainEvent.Raise(new AgencyProfileChangedEvent {
                Agency = this, OldAgencyProfile = oldAgencyProfile
            });
        }